数论
文章平均质量分 79
就是乐
Dont't try to rush things that need time to grow.
展开
-
UVa 11388----GCD LCM
题目给出gcd(a,b)和lcm(a,b),求a,b。 值得注意的是若结果有多组,输出a最小的那一组。 #include int main(void) { int T,g,l; scanf("%d",&T); while(T--) { scanf("%d%d",&g,&l); if(l%g!=0) printf("-1\n"); else原创 2015-04-10 17:00:44 · 373 阅读 · 0 评论 -
筛法求素数
int half=size/2; int sn; int prime[sn];//估算素数的个数:sn=size/in(size); bool p[half];//只需要检查奇数,因为质数除了2是偶数,其他的都是奇数 memset(p,1,sizeof(p)); for(i=0;i<cn;i++) //cn=(sqrt(size)-3)/2; { if(p[i]) {原创 2015-04-26 22:34:43 · 322 阅读 · 0 评论 -
HDU 2669----Romantic(扩展欧几里德求乘法逆元)
我觉得这个算法的难点是对递归调用的理解 具体的参见我上一篇博客 Problem Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees are Shaking, Leaves are Falling. Lov原创 2015-06-07 19:20:28 · 480 阅读 · 0 评论