国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > php开源 > 综合技术 > URAL 1295. Crazy Notions(数学啊 & 找规律)

URAL 1295. Crazy Notions(数学啊 & 找规律)

来源:程序员人生   发布时间:2015-04-08 08:35:27 阅读次数:3354次

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1295



1295. Crazy Notions

Time limit: 0.5 second
Memory limit: 64 MB
For five days robot-loader JK546L54p has been buried under the thick layer of the Sibelian plutonium slag. The terrible strike of the atmospheric electricity has led to the depressurization of the robot’s fuel elements. Who will examine this heap of fused, broken metal here, where there is no any robot technician even at distance of a hundred parsecs? Robot-commissar even did not try to investigate what happened with JK546L54p. He ordered to throw him out into dumps and that is all. Nobody noticed that positron brains of JK546L54p were still working. If only the robopsychologist was here with JK546L54p! Of course, he would be 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 his mind, and he examined them. Crazy properties, crazy theorems.
Besides, here is an example. Let’s take an expression 1n+2n+3n+4n. How much zeros does its decimal notation end with? JK546L54p solved this problem, and you, student, could you?

Input

The only line contains an integer n (1 ≤ n ≤ 300000).

Output

Output the number of zeroes the decimal notation of 1n+2n+3n+4n ends with.

Samples

input output
1
1
3
2



代码以下(找规律):

#include <cstdio> #define LL __int64 //int main() //{ // int n; // for(int i = 1; i <= 32; 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 ",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 ",a[(n⑴)%20]); } return 0; // while(~scanf("%d",&n)) // { // if(n%4 == 0) // { // printf("0 "); // } // else if((n%4==1 &&n%5==0) || n%4==3) // { // printf("2 "); // } // else // { // printf("1 "); // } // } return 0; }

贴1发他人的:

#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; long long mod=100000; long long quickmulti(long long m,long long n)//2分快速幂 { 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 ",tt); } return 0; }


生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生