I and OI
Past...
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 35 下一页
摘要: 题意:求C(N,M)的约数个数.分析:暴力分解质因数会TLE.所以先预处理.记cnt[i,j]为i的阶乘中含第j个质数的个数(这样做要先筛素数).然后C(N,M)=N!/(M!*(N-M)!)中含第i个质数的个数就是cnt[n,i]-cnt[m,i]-cnt[n-m,i].这样就OK了(刷到了pascal的rank1).code:const MAX=440;var Prime:array[0..MAX] of longint; v:array[0..MAX] of boolean; cnt:array[0..max,0..100] of longint; size,n,m,i,j,num,tm 阅读全文
posted @ 2011-08-13 13:54 exponent 阅读(475) 评论(0) 推荐(0) 编辑
摘要: 题意:求第K个和M互质的数.分析:求一个数和多少个数互质可以用容斥原理,二分一个数验证是不是第K个即可(16MS).(另一种用欧拉函数的算法更快.)code:var p,c:array[0..10000] of longint; prime:array[0..100] of longint; v:array[0..1000001] of boolean; u:array[0..100] of boolean; m,n,k,i,nx,num:longint; l,r,mid,t:int64; procedure make(k,num:longint); var o:longint; begin 阅读全文
posted @ 2011-08-13 13:48 exponent 阅读(731) 评论(0) 推荐(0) 编辑
摘要: 题意:一个3*3的矩形可以用若干个2*2的矩形去覆盖,现在给出一个最终的图,求它是否合法.分析:就是拓扑排序.code:const yes='THESE WINDOWS ARE CLEAN'; no='THESE WINDOWS ARE BROKEN';var sta:array[1..9,0..1] of longint=((1,1),(1,2),(1,3), (2,1),(2,2),(2,3), (3,1),(3,2),(3,3)); map:array[0..10,0..10] of longint; link:array[0..10,0..10] of 阅读全文
posted @ 2011-08-13 13:38 exponent 阅读(315) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 35 下一页