2013年7月24日

数论欧几里德定理的运用

摘要: 欧几里得/扩展欧几里得/模线性方程组(中国剩余定理以及mod不互质的情况)欧几里得/扩展欧几里得/模线性方程组(中国剩余定理 以及mod不互质的情况)/***********欧几里得算法**************/辗转相除法求最大公约数。GCD(a,b)=GCD(b,a mod b)稍微证明一下:(参考:算法导论)证明的思路是大致是这样的:证明 GCD(a,b) | GCD(b,a mod b) 并且 GCD(b,a mod b) | GCD(a,b)先证GCD(a,b) | GCD(b,a mod b):设 d=GCD(a,b),则d|a 并且 d|b那么 a=r+kb (k为整数)也就是 阅读全文

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

uva 11806 容斥原理+dfs

摘要: In most professional sporting events, cheerleaders play a major role in entertaining the spectators. Their roles are substantial during breaks and prior to start of play. The world cup soccer is no exception. Usually the cheerleaders form a group and perform at the centre of the field. In addition t 阅读全文

posted @ 2013-07-24 09:13 雄.. 阅读(222) 评论(0) 推荐(0)

2013年7月23日

uva 11401 数三角形

摘要: Triangle CountingInput:Standard InputOutput:Standard OutputYou are givennrods of length 1, 2…, n. You have to pick any 3 of them & build a triangle. How many distinct triangles can you make? Note that, two triangles will be considered different if they have at least 1 pair of arms with different 阅读全文

posted @ 2013-07-23 19:55 雄.. 阅读(283) 评论(0) 推荐(0)

hdu 1104 数论+bfs

摘要: RemainderTime Limit: 6000/3000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2122Accepted Submission(s): 449 Problem DescriptionCoco is a clever boy, who is good at mathematics. However, he is puzzled by a difficult mathematics problem. The problem is: Given three in 阅读全文

posted @ 2013-07-23 12:43 雄.. 阅读(193) 评论(0) 推荐(0)

poj 1061 青蛙的约会(二元一次不定方程)

摘要: Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,你被要求写一个程序来判断这两只青蛙是否能够碰面,会在什么时候碰面。 我们把这两只青蛙分别叫做青蛙A和青蛙B,并且规定纬度线上东经0度处为原点,由东往西为正方向,单位长度1米,这样 阅读全文

posted @ 2013-07-23 09:27 雄.. 阅读(314) 评论(0) 推荐(0)

2013年7月20日

Nk 1214 Relatives(欧拉函数)

摘要: Time Limit: 1500 ms Memory Limit: 10000 kB Total Submit : 234(77 users)Accepted Submit : 102(72 users)Page View : 3852Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, 阅读全文

posted @ 2013-07-20 16:06 雄.. 阅读(182) 评论(0) 推荐(0)

Nk 1430 Divisors(因子数与质因数)

摘要: Time Limit: 5000 ms Memory Limit: 10000 kB Total Submit : 432 (78 users) Accepted Submit : 108 (57 users) Page View : 3479 Font Style: Aa Aa Aa Your task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful computation? In 阅读全文

posted @ 2013-07-20 15:16 雄.. 阅读(327) 评论(0) 推荐(0)

2013年7月19日

Nk 1430 Fibonacci(二分矩阵乘幂)

摘要: AC代码:#includeusing namespace std;int a[3][3];int d[3][3];int t[3][3];int temp[3][3];void binary(int n){ int i,j,k; while(n) { if(n%2) { for(i=1;i>n,n+1) { if(!n) { cout<<0<<endl; continue; } memset(a,0,sizeof(a));... 阅读全文

posted @ 2013-07-19 22:06 雄.. 阅读(203) 评论(0) 推荐(0)

2013年6月11日

三个水杯(bfs+字典树)

摘要: 三个水杯时间限制:1000 ms | 内存限制:65535 KB难度:4描述 给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子。三个水杯之间相互倒水,并且水杯没有标识,只能根据给出的水杯体积来计算。现在要求你写出一个程序,使其输出使初始状态到达目标状态的最少次数。 输入第一行一个整数N(0<N<50)表示N组测试数据 接下来每组测试数据有两行,第一行给出三个整数V1 V2 V3 (V1>V2>V3 V1<100 V3>0)表示三个水杯的体积。 第二行给出三个整数E1 E2 E3 (体积小于等于相应水杯体积)表示我们需要的最终状态输出每 阅读全文

posted @ 2013-06-11 18:39 雄.. 阅读(421) 评论(0) 推荐(0)

2013年5月26日

hdu 3094 树的删边游戏

摘要: A tree gameTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 383Accepted Submission(s): 180 Problem DescriptionAlice and Bob want to play an interesting game on a tree. Given is a tree on N vertices, The vertices are numbered from 1 to N. vertex 1 r 阅读全文

posted @ 2013-05-26 21:33 雄.. 阅读(405) 评论(0) 推荐(0)

导航