Title Link: http://acm.timus.ru/problem.aspx?space=1&num=1295
1295. Crazy Notionstime limit:0.5 Second
Memory limit:64 MB
For five days Robot-loader jk546l54p have been buried under the thick layer of the Sibelian plutonium slag. The terrible strike of the atmospheric electricity have led to the depressurization of the robot ' s fuel elements. Who would examine this heap of fused, broken metal here, where there was no any robot technician even at distance of a Hundr Ed parsecs? Robot-commissar even did not a try to investigate what happened with jk546l54p. The He ordered to the throw him out into the dumps and that's all. Nobody noticed that positron brains of jk546l54p were still working. If only the robopsychologist is here with jk546l54p! Of course, he would is killed with the hard gamma radiation in a moment, but ... If He attached the visualizer of thoughts to the fused connectors of jk546l54p! He would see the strange performance. Robot was creating! No, I am not joking. He was investigating. Semi casual objects arose in its mind, and he examined them. Crazy properties, Crazy theorems. Besides, here's an example. Let ' s tAke an expression 1
N+2
N+3
N+4
N. How much zeros does it decimal notation end with? jk546l54p solved this problem, and you, student, could? Inputthe contains an integer
N(1≤
N≤300000). Outputoutput the number of zeroes the decimal notation of 1
N+2
N+3
N+4
NEnds with. Samples
The code is as follows (rule-finding):
#include <cstdio> #define LL __int64//int main ()//{//int n;//for (int i = 1; i <=; i++)//{// ll ans1 = 1;//ll ans2 = 1;//ll ans3 = 1;//ll ans4 = 1;//for (int j = 1; J <= I; j + +)// {//ans2*=2;//ans3*=3;//ans4*=4;//}//int cnt = 0;//LL ans = ans1+ans2+ans3+ans4;//while (ans)//{//if (ans%10 = = 0)//{//cnt++; ans/=10;//}//else//{//break;//}// }//printf ("%d:: ans:%d\n", i,cnt);//}//return 0;//}int main () {int n; int a[30]= {1,1,2,0,2,1,2,0,1,1,2,0,1,1,2,0,1,1,2,0}; while (~SCANF ("%d", &n)) {printf ("%d\n", a[(n-1)%20]); } return 0;//while (~scanf ("%d", &n)//{//if (n%4 = = 0)//{//printf ("0\n");// }//else if ((n%4==1 &&n%5==0) | | N%4==3)//{//printf ("2\n");//}//else//{//printf ("1\n");/} } return 0;}
to post someone else's:
#include <stdio.h> #include <iostream> #include <algorithm>using namespace Std;long long mod=100000; Long Long Quickmulti (long long M,long long N)//two-minute fast power { long long Ans=1; Long long I; while (n) { if (n&1) ans= (M*ans)%mod; M= (m*m)%mod; n>>=1; } return ans;} int main () { long long n; while (scanf ("%lld", &n)!=eof) { long long Ans=1; Ans+=quickmulti (2,n); Ans%=mod; Ans+=quickmulti (3,n); Ans%=mod; Ans+=quickmulti (4,n); Ans%=mod; Long long Tem=ans; Long long tt=0; while (tem%10==0) { tem/=10; tt++; } printf ("%lld\n", TT); } return 0;}
URAL 1295. Crazy Notions (Math & Law)