摘要: 这题分2种情况:1) n>=m时,k!%m=0(k>=m),所以只需令n=m-1即可;2) n#include#include#include#include#include#includeusing namespace std;int main(){ int n,i,j,k,t,m; char a[100]; cin>>t; while(t--) { cin>>a>>m; i=strlen(a); if(i>7) n=m-1; else { sscanf(a,"%d",&n); if(n>=m) n=m- 阅读全文
posted @ 2013-07-20 16:38 _随心所欲_ 阅读(116) 评论(0) 推荐(0)
摘要: 好题!!!没话说……用到的知识面很多,这题的难点在于公式的推导。原始推导过程见:http://hi.baidu.com/spellbreaker/item/d8bb3bda5af30be6795daa93这个过程有点小问题,改进后的见:http://blog.csdn.net/acm_cxlove/article/details/7868589下面是自己敲的代码: 1 /************************************************************************* 2 > File Name: xh.cpp 3 > Au... 阅读全文
posted @ 2013-07-20 09:03 _随心所欲_ 阅读(322) 评论(0) 推荐(0)
摘要: 总的来说,这题要2次用到polya定理。由题目条件A*A=B*B+1,变形为(A-1)*(A+1)=K*B*B;分别分解A-1和A+1的质因数,在合并在一起。第一步:搜索B,对B*B的正方形涂色,基本的polya定理搞定,即C^(B*B)+C^((B*B+1)/2)+2*C^((B*B+3)/4).第二步:搜索K,在A-1和A+1的因子中搜索,这样不会超时,在用polya定理,最后在结果上乘C就可以了…… 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using na... 阅读全文
posted @ 2013-07-19 16:47 _随心所欲_ 阅读(255) 评论(0) 推荐(0)
摘要: 高精度+polya原理可以搞定思路:设边长为n的正方形,c种颜色。旋转只有 0,90,180,270度三种旋法。旋0度,则置换的轮换数为n*n旋90度,n为偶数时,则置换的轮换数为n*n/4,n为奇数,则置换的轮换数为(n*n-1)/4+1旋180度,n为偶数时,则置换的轮换数为n*n/2,n为奇数,则置换的轮换数为(n*n-1)/2+1旋270度,n为偶数时,则置换的轮换数为n*n/4,n为奇数,则置换的轮换数为(n*n-1)/4+1反射 沿对角反射两种,沿对边中点连线反射两种n为偶数时,沿对边中点连线反射两种的置换轮换数为 n*n/2 沿对角反射两种的置换轮换数为 (n*n-n)/2+nn 阅读全文
posted @ 2013-07-19 10:25 _随心所欲_ 阅读(459) 评论(0) 推荐(0)
摘要: 完全是套用polya模版……#include#include#include#include#include#includeusing namespace std;int prime[30005],m,mod=1000000007;bool f[30005];__int64 extend(__int64 a,__int64 b,__int64 &x,__int64 &y){ __int64 d; if(b==0) { x=1;y=0; return a; } else { d=extend(b,a%b,x,y); __int64 t=x; x=y; y=t-a/b*y; } r 阅读全文
posted @ 2013-07-18 19:32 _随心所欲_ 阅读(214) 评论(0) 推荐(0)
摘要: 计算几何,主要是排序问题,其他都很好做……#include#include#include#include#include#includeusing namespace std;struct seg{ double k,b; double x1,y1; double x2,y2; bool flag;}an[10002];int same(double a,double b){ if(fabs(a-b)>1e-8) return 0; return 1;}bool less(double a,double b){ if(a-b>1e-8) return 0; return 1;}b 阅读全文
posted @ 2013-07-18 16:32 _随心所欲_ 阅读(212) 评论(0) 推荐(0)
摘要: 这题当时竟然没看啊……找规律:求和m+m+m-1+m-1+……前n项#include#include#include#include#include#includeusing namespace std;int main(){ __int64 n,m,i,sum; while(scanf("%I64d%I64d",&m,&n)!=EOF) { sum=0; for(i=0;i<n/2;i++) { sum+=m-i; } sum=2*sum+m-n/2; printf("%I64d\n",sum); } return 0;} 阅读全文
posted @ 2013-07-18 14:45 _随心所欲_ 阅读(309) 评论(0) 推荐(0)
摘要: ……但是没仔细看,直接跳过了这题直接枚举就可以过了#include#include#include#include#include#includeusing namespace std;__int64 a[5];int n;__int64 swap(__int64 x){ if(n==1) return a[1]*x+a[0]; else if(n==2) return a[2]*x*x+a[1]*x+a[0]; else if(n==3) return a[3]*x*x*x+a[2]*x*x+a[1]*x+a[0]; else return a[4]*x*x*x*x+a[3]*x*x*x+a 阅读全文
posted @ 2013-07-18 14:07 _随心所欲_ 阅读(333) 评论(0) 推荐(0)
摘要: 这题在比赛的时候不知道怎么做,后来看了别人的解题报告,才知道公式sn=(a+sqrt(b))^n+(a-sqrt(b))^n;具体推导 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 struct ma 9 {10 __int64 a[2][2];11 void init()12 {13 a[0][0]=a[1][1]=1;14 a[0][1]=a[1][0]=0;15 }16 };17 int m... 阅读全文
posted @ 2013-07-18 11:27 _随心所欲_ 阅读(282) 评论(0) 推荐(0)
摘要: 求分数的最小公倍数。对于a/b c/d 先化简为最简分数,分数最小公倍数=分子的最小公倍数/分母的最大公约数。#include#include#include#include#include#includeusing namespace std;__int64 gcd(__int64 a,__int64 b){ __int64 t; if(a>t; while(t--) { scanf("%d/%d %d/%d",&a,&b,&c,&d); g=gcd(a,c); x=a/g*c; b*=c/g; d*=a/g; y=gcd(b,d); 阅读全文
posted @ 2013-07-17 20:52 _随心所欲_ 阅读(182) 评论(0) 推荐(0)