摘要: 这道题可以说是模拟,也可以说是数学题;以前在codeforce做过一题类似的,但是写的好长好长,后来看了大神写的代码后被折服... 1 #include 2 int main(){ 3 int n,a,b,c,d,e,f,x,y; 4 int u[4]={0,5,3,1}; 5 while(1){ 6 scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f); 7 if(a==0&&b==0&&c==0&&d==0&&e==0&&am 阅读全文
posted @ 2013-08-25 22:07 Yours1103 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 简单模拟: 1 #include 2 #include 3 using namespace std; 4 int n,m,cnt; 5 int a[1010],b[1010]; 6 7 inline bool judge() 8 { 9 for(int i=0;i<n;i++)10 if(a[0]!=a[i]) return false;11 return true;12 }13 14 int main()15 {16 while(scanf("%d",&n)==1)17 {18 if(n==0) return 0;19 ... 阅读全文
posted @ 2013-08-25 22:03 Yours1103 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 暑假集训做的第一个题,模拟,挺简单的,不过要细心点...没什么好说的,直接贴代码; 1 #include 2 #include 3 using namespace std; 4 5 bool rec[33][33]; 6 int n,x,y; 7 char c; 8 9 int main()10 {11 while(scanf("%d",&n)!=EOF)12 {13 int m=1;14 while(n--)15 {16 scanf("%d%d",&x,&y);17 memse... 阅读全文
posted @ 2013-08-25 21:59 Yours1103 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 又是个水题,刚刚开始没有用搜索,因为对于反素数有:n=2^t1*3^t2^5^t3*7^t4..... 这里有 t1>=t2>=t3>=t4。而且相同的因数的情况下,素数越不同越好。哪知道这个方法错了! = =。看来还得中规中矩得用dfs。我觉得还可以优化下,感觉搜索干了很多无用的活儿。搜索还得好好练练啊... 1 #include 2 #define LL long long 3 using namespace std; 4 int prim[16] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47 }; 阅读全文
posted @ 2013-08-25 21:31 Yours1103 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 每个数都可以分解成素数的乘积:写成指数形式:n=p1^e1*p2^e2*...*pn^en;(p都是素数)那么n的因数的数量m=(e1+1)*(e2+1)*...*(en+1);所以用筛选法筛出1-n的各个素因数的数量;然后容易得到n!的各个素因数的数量;因为C(n,k)=n!/k!/(n-k)!;所以接下来的事就容易办了.....我的代码: 1 #include 2 using namespace std; 3 int e[432][432],sum[432][432],n,num,kk; 4 bool prim[432]; 5 long long ans; 6 int main() 7 { 阅读全文
posted @ 2013-08-25 19:34 Yours1103 阅读(145) 评论(0) 推荐(0) 编辑