上一页 1 2 3 4 5 6 ··· 14 下一页
摘要: 题目:http://poj.org/problem?id=2142给出 a b d,找出 x 和 y 能够组合出 d,也就是满足 a * x + b * y = d,a 和 b 不一定是在天枰的同一边,利用扩展欧几里得求出 x , y, x,y可能为负值,把 x y 转化为最小的正整数,然后利用 最小的 x ,根据 ty = (d - a * x) / b,和最小的 y 根据 tx = (d - b * y) / a,判断 x + ty 和 y + tx的大小,然后输出结果View Code 1 typedef long long ll; 2 int exgcd(int a,int b,in. 阅读全文
posted @ 2012-11-15 10:35 AC_Girl 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1730给出 x 求出最大的p 满足 x = b ^ p;因为p 最大是 32,所以枚举 p,如果一个数本身是素数,那么一定输出 1,注意如果 x < 0时,p 不可能是 偶数View Code 1 typedef long long ll; 2 bool isprime(ll a) 3 { 4 ll i; 5 for(i = 2; i * i <= a; i++) 6 { 7 if(a % i == 0) return false; 8 } 9 return true;10 }... 阅读全文
posted @ 2012-11-11 10:45 AC_Girl 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1665http://poj.org/problem?id=16661665 :读清题意,这个题目也就是几行代码。题目里给的那个 n 是转的圈数,而不是转速,注意单位间的换算1666:纯粹的一个模拟,数据n开到了10000,具体多少好像题目没说View Code 1 const int N = 10000; 2 int cand[N]; 3 int main() 4 { 5 int i,j; 6 int n; 7 while(~scanf("%d",&n)) 8 { 9 if(n == ... 阅读全文
posted @ 2012-11-10 16:32 AC_Girl 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1565刷水题刷的都鄙视自己了View Code 1 typedef long long ll; 2 char str[40]; 3 ll mypow(int len) 4 { 5 int i; 6 ll temp = 1; 7 for(i = 0; i < len; i++) 8 temp *= 2; 9 return temp;10 }11 int main()12 {13 int i,len;14 while(~scanf("%s",str))15 {16 ... 阅读全文
posted @ 2012-11-10 11:34 AC_Girl 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1306求C(n,m),n m 最大为100,任何一个数都可以表示成 质因子的幂的乘积 x = p1 ^ a1 * p2 ^ a2 ~~~pn ^ an,这样对 C(n,m) = n! / ((n - m)! * m!),对 分别对 n,m,(n - m)分解质因子,然后用质因子的幂数想减,最后得到的(p1 ^ sum1 * p2 ^ sum2 ~~~pn ^ sumn),就为结果。View Code 1 typedef long long ll; 2 const int N = 101; 3 int prime[N]; 4 bool. 阅读全文
posted @ 2012-11-10 11:20 AC_Girl 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1305题意:从 1 到 n 中找出 x y z 三个数满足:x ^ 2 + y ^ 2 = z ^ 2,且(x < y < z, x y z 两两互质)这些条件的(x,y,z)共有多少个,第二, 在 1到 n 中不是 x,y,z任意一个或两个或三个的整数倍的数有多少很暴力的方法,枚举 x y,然后判断zView Code typedef long long ll;bool mark[1000001];int gcd(int a,int b){ if(!b) return a; else return gcd(b,a % b 阅读全文
posted @ 2012-11-10 10:43 AC_Girl 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1091按照我想的应该用高精度写的,写高精度求幂,和加减运算,但是题目数据不强,long long也过了,就懒得写高精度了,题意是:找出 n + 1 个数( <= m ) 这(n + 1)个数最大公倍数是 1,首先求出 m 的所有质因子,然后用这些质因子构成 (n + 1)个数最大公倍数不是 1的情况,最后用总数减去这些情况View Code 1 typedef long long ll; 2 const int N = 20001; 3 bool vis[N]; 4 int prime[N]; 5 int num,tnum; 6 阅读全文
posted @ 2012-11-10 09:12 AC_Girl 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=1142如果一个数本身是素数,那么这个数不是Smith Numbers,如果一个数不是素数,那么10 ^ 4( n 最多 8 位)以内一定有它的质因子,打出10000以内的素数,分解求和,从 n + 1往后枚举View Code 1 const int N = 10001; 2 int prime[N]; 3 bool vis[N]; 4 int num,tnum; 5 void is_prime() 6 { 7 int i,j; 8 num = 0; 9 for(i = 2; i <= N; i++)10 ... 阅读全文
posted @ 2012-11-03 21:43 AC_Girl 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.timus.ru/problem.aspx?space=1&num=1132很无奈的一个题,看解题报告没看懂怎么回事,问的队友,然后不知道他怎么找的那些资料,然后我就是直接看的链接,http://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm再加上 n == 2时特判,然后就是 r == n - r 时,输出一个,然后就是按照那个算法步骤算了View Code 1 typedef long long ll; 2 ll tmod; 3 ll mod(ll n,ll p) 4 { 5 ll temp. 阅读全文
posted @ 2012-11-01 21:35 AC_Girl 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 题目:http://codeforces.com/contest/237/problem/A那么简单的题目,还是忘了考虑n = 1时的情况了。。。View Code 1 typedef long long ll; 2 const int N = 100001; 3 char str[N][10]; 4 int main() 5 { 6 int n; 7 int i; 8 while(~scanf("%d",&n)) 9 {10 getchar();11 for(i = 0; i < n; i++)12 {13 ... 阅读全文
posted @ 2012-10-26 22:11 AC_Girl 阅读(177) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 14 下一页