2013年8月5日

uva 1426 离散平方根

摘要: 1426 - Discrete Square RootsTime limit: 3.000 secondsA square root of a numberxis a numberrsuch thatr2=x. A discrete square root of a non-negative integerxis a non-negative integerrsuch thatr2xmodN,0r, whereNis a specific positive integer and mod is the modulo operation.It is well-known that any pos 阅读全文

posted @ 2013-08-05 14:38 雄.. 阅读(362) 评论(0) 推荐(0)

2013年7月30日

uva 550 有趣的乘法(dfs)

摘要: 题目大意:给三个数A(进制)、B(如*****7的最后一个数字7)、C(*****7*4的后面的因数4)求符合条件下的第一个因数的位数最少例子:179487 * 4 = 717948 (10进制)注意到没7*4%10=8,8就是第一个因数的十位数字,进位7*4/10=2;第二个数字(8*4+2)%10=4,进位(8*4+2)/10=3;..........当一个数字等于B时,且前一个进位上来的值为0时候符合题意;AC 代码:#include#includeusing namespace std;int num,flag;int A,B,C;void dfs(int a,int b,int c, 阅读全文

posted @ 2013-07-30 21:21 雄.. 阅读(185) 评论(0) 推荐(0)

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)

2013年7月28日

uva 10692 高次幂取模

摘要: Huge ModInput:standard inputOutput:standard outputTime Limit:1 secondThe operator for exponentiation is different from the addition, subtraction, multiplication or division operators in the sense that the default associativity for exponentiation goes right to left instead of left to right. So unless 阅读全文

posted @ 2013-07-28 18:07 雄.. 阅读(271) 评论(0) 推荐(0)

2013年7月26日

uva 10515 规律打表

摘要: Problem G Power et al. Input:Standard InputOutput:Standard OutputFinding the exponent of any number can be very troublesome as it grows exponentiallyJ. But in this problem you will have to do a very simple task. Given two non-negative numbersmandn, you will have to find the last digit ofmnin decimal 阅读全文

posted @ 2013-07-26 22:44 雄.. 阅读(297) 评论(0) 推荐(0)

uva 11426 线性欧拉函数筛选+递推

摘要: Problem J GCD Extreme (II)Input:Standard InputOutput:Standard OutputGiven the value of N, you will have to find the value of G. The definition of G is... 阅读全文

posted @ 2013-07-26 10:30 雄.. 阅读(280) 评论(0) 推荐(0)

2013年7月25日

poj 2115 二元一次不定方程

摘要: C LooooopsTime Limit:1000MSMemory Limit:65536KTotal Submissions:14765Accepted:3719DescriptionA Compiler Mystery: We are given a C-language style for loop of typefor (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and while variable is.. 阅读全文

posted @ 2013-07-25 10:09 雄.. 阅读(235) 评论(0) 推荐(0)

2013年7月24日

poj 2891 模线性方程组求解

摘要: Strange Way to Express IntegersTime Limit:1000MSMemory Limit:131072KTotal Submissions:8005Accepted:2378DescriptionElina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following:Choosekdifferent positive integersa1,a2,… 阅读全文

posted @ 2013-07-24 22:37 雄.. 阅读(224) 评论(0) 推荐(0)

导航