2013年7月29日

uva 10710 快速幂取模

摘要: //题目大意:输入一个n值问洗牌n-1次后是不是会变成初始状态(Jimmy-number),从案例可看出牌1的位置变化为2^i%n,所以最终判断2^(n-1)=1(mod n)是否成立#include#include#include#includeusing namespace std;long long Montgomery(long long a,long long b,long long c){ long long t=1; while(b) { if(b%2) t=t*a%c; b/=2; a=a*a%c... 阅读全文

posted @ 2013-07-29 22:35 雄.. 阅读(241) 评论(0) 推荐(0)

uva 10140 素数筛选(两次)

摘要: #include#include#include#includeusing namespace std;bool flag[50010];int prime[8000];bool r[1000010];int num;void Init(){ int i,j; num=0; memset(flag,true,sizeof(flag)); flag[1]=flag[0]=0; for(i=2;i>a>>b) { if(a==1) a++;//a=1的情况 min=20000000; max=0; mems... 阅读全文

posted @ 2013-07-29 15:14 雄.. 阅读(242) 评论(0) 推荐(0)

uva 10090 二元一次不定方程

摘要: MarblesInput:standard inputOutput:standard outputI have some (say,n) marbles (small glass balls) and I am going to buy some boxes to store them. The boxes are of two types:Type1: each box costsc1Taka and can hold exactlyn1marblesType2: each box costsc2Taka and can hold exactlyn2marblesI want each of 阅读全文

posted @ 2013-07-29 11:03 雄.. 阅读(242) 评论(0) 推荐(0)

导航