View Code #include<cstdio> #include<cstring> __int64 n, p, a[4] = {2, 3, 5, 7}; int main() { int i, j; while( ~scanf("%I64d", &n) && n) { __int64 ans = 1; for(i = 0; i < 4; i++) { __int64 m = n; p = 0; ... Read More
posted @ 2012-12-04 23:19
To be an ACMan
Views(156)
Comments(0)
Diggs(0)
题意:统计n!后面有几个0, 2肯定够用,只要算n!里有几个5就可以了View Code #include<cstdio>#include<cstring>int main(){ int cas, n; scanf("%d", &cas); while(cas--) { scanf("%d", &n); int s = 5, ans = 0; while(s <= n) ans += n/s, s *= 5; printf("%d\n", ans); } return 0;} Read More
posted @ 2012-12-04 22:01
To be an ACMan
Views(159)
Comments(0)
Diggs(0)
分成2段a和b,若n为奇数, a,b一奇一偶, 若n为偶数,a,b都为偶数。假设长度为L,每段的次数是 1+2+3+......+L = (L+1)*L/2, a,b两段加起来就是答案;View Code #include<cstdio>#include<cstring>__int64 n, a, b;int main(){ while( ~scanf("%I64d", &n)) a = n>>1, b = n - a, printf("%I64d\n", (a*a+b*b-n)>>1); retu Read More
posted @ 2012-12-04 21:47
To be an ACMan
Views(186)
Comments(0)
Diggs(0)
View Code #include<cstdio>#include<cstring>#include<cmath>bool vis[10004];void init() { int i, j; for(i = 2; i * i <= 10000; i++) for(j = i*i; j <= 10000; j += i) vis[j] = 1; vis[1] = 1; //注意}int main(){ int n, i; // 注意14 = 7 + 7 init(); while( ~scanf("%d", &n)) Read More
posted @ 2012-12-04 21:18
To be an ACMan
Views(144)
Comments(0)
Diggs(0)
View Code #include<cstdio>#include<cstring>#include<cmath>int p[1004], tot;bool vis[1104];void init() // 素数打表,注意本题1也是素数{ int i, j; for(i = 2; i * i <= 1000; i++) for(j = i*i; j <= 1000; j += i) vis[j] = 1; for(i = 1; i <= 1000; i++) if(!vis[i])p[tot++] = i; }int mai... Read More
posted @ 2012-12-04 21:09
To be an ACMan
Views(248)
Comments(0)
Diggs(0)
很详细的资料:http://blog.csdn.net/lulipeng_cpp/article/details/7612490补充以下结论,自己推的,解释了以上博客里的疑惑。方程ax+by=gcd(a,b),即 模线性方程ax≡d(mod b) ,令d =gcd(a,b)。假设模线性方程的解为 x0, y0。结论1:则有 max( abs(x0),abs(y0) )< max( abs(a), abs(b) );结论2:若d = a, 则 x = 1,y = 0; 若 d = b,则 x = 0,y = 1;结论3:则方程的所有解为 x = x0 + b/d*i, y = y0 - a Read More
posted @ 2012-12-04 19:55
To be an ACMan
Views(436)
Comments(0)
Diggs(0)