0% found this document useful (0 votes)
111 views

FERT CODE SPOJ Sol

This document provides solutions to problems on the spoj competitive programming website. It includes code for solving the FERT21_0 or Matches problem on spoj, which involves calculating the nth digit of large numbers by repeatedly multiplying by 5. Readers are encouraged to understand the logic rather than just copying code. The author can be contacted by email for help with additional spoj problems.

Uploaded by

Viraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

FERT CODE SPOJ Sol

This document provides solutions to problems on the spoj competitive programming website. It includes code for solving the FERT21_0 or Matches problem on spoj, which involves calculating the nth digit of large numbers by repeatedly multiplying by 5. Readers are encouraged to understand the logic rather than just copying code. The author can be contacted by email for help with additional spoj problems.

Uploaded by

Viraj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

SPOJSOLUTIONS

Hereyouwillfindsolutionsofmanyproblemsonspoj.Ifyouwantsolutionofsomeproblemwhichisnotlistedinblogorhavedoubtregardinganyspojproblem(whichihavesolved)oranypro
[email protected]@gmail.com
Andmyhumblerequesttoyouallthatdon'tcopythecodeonlytrytounderstandthelogicandalgorithmbehindthecode.Ihavestartedthisbecauseifyoutriedashardasyoucanandstill
thenyoucanrefertothis.
YoucanreadmyanswerhowtostartcompetitiveprogrammingCLICKHERE

Thursday,March27,2014

FERT21_0Matches
Matches

belowgivencodeisforfert21_0spojormatchesspoj.
youcanmakethiscodemorefasterusingcharacterarrayansfasti/o
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<climits>
#include<cfloat>
#include<map>
#include<fstream>
#include<sstream>
#include<bits/stdc++.h>
#include<climits>
usingnamespacestd;
stringarr[1009];
stringmultiply(strings,inta)
{
inti,carry=0,j;
stringtemp;
charc;
for(i=s.size()1;i>=0;i)
{
j=s[i]48;
c=(j*a+carry)%10+48;
carry=(j*a+carry)/10;
temp=c+temp;
}
if(carry!=0)
c=carry+48,temp=c+temp;
returntemp;
}
voidpre()
{
arr[0]=49;
for(inti=1;i<=1000;i++)
arr[i]=multiply(arr[i1],5);
}
intmain()
{
intt;
scanf("%d",&t);
pre();
while(t)
{
intn,l,p;
ios_base::sync_with_stdio(false);
scanf("%d",&n);
if(n==1)

cout<<"1"<<endl;
else
{
cout<<"0.";
p=arr[n1].size();
l=abs((n1)p);
for(inti=0;i<l;i++)
cout<<"0";
cout<<arr[n1]<<endl;
}
}
return0;
}

PostedbyNishantRajat5:48PM
EmailThisBlogThis!SharetoTwitterSharetoFacebookSharetoPinterest
Labels:implementation

NewerPostOlderPostHome
Subscribeto:PostComments(Atom)

SearchThisBlog
Loading...

ALLPOST
2015(34)
October(9)
September(5)
August(5)
June(1)
February(6)
January(8)
2014(143)
December(6)
November(9)
October(15)
September(1)
August(9)
July(5)
June(10)
May(11)
April(7)
March(31)
SIRNUMSSIRCHIRAGANDMAGIC
NUMBERS
BLOPEROperators
RMIDRunningMedianRevisited
AMSCO1TheAMSCOcipher
AMSCO2DeciphertheAMSCOcipher
ICPC12CTheEncryptedPassword
FERT21_0Matches
RMIDRunningMedian
GSSQUNCESequence
IITWPC4DArrangementValidity
binaryindexedtreeBIT
JOKER1KnifesAreFun
QN01XORGame
IITKWPCOCreateCollections
LOOPEXPLoopExpectation
SPCJGopuandCreateCollectionsPartTwo
BOGGLEBoggleScoring
IITWPC4CMagguandVectors
AKVOD05RossgeneratesData
GOPI_SWGopiandSandwich
MSCHEDMilkScheduling
GSHOPRamaandFriends
BTCD14AGameofPips
LKSLargeKnapsack
HLP_RAMSTopperRamaRao
EMTY2CanYouMakeItEmpty
TRIGALGEEasyCalculation
SNGMSGEncodeMessage

SNGMSGEncodeMessage
SYNC13CWHATACOACCIDENT
PRISMSATRIANGULARPRISM
TipTopGameTIPTOP
February(30)
January(9)
2013(34)
December(34)

FacebookFollowers

Subscribe

Posts

Comments

pagehits

Therewasanerrorinthisgadget

FollowbyEmail
Emailaddress...

Submit

Google+Followers

Contributors
NishantRaj
NishantRaj

Labels
math(27)implementation(23)Graph(12)
BinarySearch(11)prime(11)Dynamic
Programming(10)BFS(8)BIT(7)Strings
(7)easy(7)primefactorization(7)DFS(6)
greedy(6)Hash(5)SegmentTree(5)Suffix
Array(4)AVLTree(2)ConvexHull(2)Game
Theory(2)HeightBalancedTree(2)Z
function(2)factorization(2)fibonacci(2)
matrixexponentiation(2)sorting(2)2DBIT
(1)BipartiteGraph(1)Editdistance(1)
GrundyNumbers(1)Heap(1)LCP(1)
LinkedListdatastructure(1)PolicyBased
DataStructure(1)PriorityQueue(1)Rolling
Hash(1)TriesDatastructure(1)contest(1)
floydwarshall(1)inversemodulo(1)
moderate(1)offlinequery(1)queue(1)
sieve(1)stack(1)stringmatching(1)
tetranacci(1)tree(1)twopointer(1)

PopularPosts

AGGRCOWAggressivecows

BelowgivencodeisforAGGRCOWspojAggressivecowsspoj.Hint:ThinkBinarysearch,#include<bits/stdc++.h>usingnamesp...
PPATHPrimePath
PrimePathBelowgivencodeisforPPATHspojorPrimepathspoj.Hint:UseBFSandsieve.#include<bits/stdc++.h>us...
PT07ZLongestpathinatree
LongestpathinatreeGivenbelowcodeisforPTZ07ZspojorLongestpathinatreespoj.YoucansolvethisusingDFSofapplyi...
Google+BadgePALINTheNextPalindrome
Itisasolutiontothe5thandoneofmostattractiveproblemtonovice,aswellasexperiencedhackeriftheyhaven'tdonewithit...
SegmenttreeGSS3&GSS1
Firstofallreadaboutsegmenttreeanditbasicfunctioning.YoucanreaditfromHERE.GivenbelowcodeisforGSS3&GSS1spoj...

Myotherblogs

RealThrills

NISHNATRAJ.PoweredbyBlogger.

You might also like