上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: 题目:Summation of Four Primes思路:好像有个什么定理说是任意的一个偶数都可以表示成两个素数的和,所以对于输入的n,最糟糕的情况是n=8=2+2+2+2,小于8的无解,对于大于8的情况,如果是奇数,我们就拿一个2和一个3出来,如果是偶数,我们就拿两个2出来,那么剩下的就是求某个偶数等于两个素数之和,继续暴力#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iostream>using namespace 阅读全文
posted @ 2013-06-21 14:21 over_flow 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 题目:Factovisors思路:直接质因式分解除数,然后求得阶乘各质因子的幂是否大于除数的,注意特判情况(存在一个较大的素数,这个要判断n是不是大于等于那个很大的素数)#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;#define maxn 60000bool vis[maxn];int prime[maxn];int cnt[maxn];int n_prime= 阅读全文
posted @ 2013-06-21 14:03 over_flow 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目:Euclid Problem思路:裸的扩展欧几里得#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <cstring>using namespace std;long long exgcd(long long a,long long b,long long &x,long long &y){ if(b==0) { x=1; y=0; return a; } else { long long a... 阅读全文
posted @ 2013-06-21 11:40 over_flow 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 题目:Carmichael Numbers思路:直接判是不是素数然后满不满足费马小定理就行了#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iostream>using namespace std;#define maxn 66000int vis[maxn];void Prime(){ memset(vis,1,sizeof(vis)); vis[0]=vis[1]=0; for(int i=2;i*i<maxn; 阅读全文
posted @ 2013-06-21 11:25 over_flow 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目:Light, more light思路:之前做过了的,直接判是不是完全平方数就可以知道约数的奇偶性了#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iostream>using namespace std;int main(){ long long n; while(scanf("%lld",&n),n) { long long tmp=(long long)sqrt(n); if(tmp 阅读全文
posted @ 2013-06-21 11:24 over_flow 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 题目:Factoring Large Numbers思路:开始一看,感觉暴不了,然后题目中有说大于100w的素因子只有一个,所以那就暴100w以内的质因子就行,最后剩下的不等于1的话,就是一个大于100w的素因子直接输出#include <cstdio>#include <iostream>#include <cmath>#include <algorithm>#include <cstring>using namespace std;#define maxn 1000001bool vis[maxn];int prime[maxn] 阅读全文
posted @ 2013-06-21 10:47 over_flow 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目:How many zero's and how many digits ?思路:求0的,我们先把base分解质因式,然后求num对base各质因式非0的幂的倍数,取最小值。 求位数的,只求取log10,注意一下精度问题#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;#define maxn 810int vis[maxn];int prime[maxn 阅读全文
posted @ 2013-06-21 09:39 over_flow 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 题目:Multiplying by Rotation思路:求base进制下,长度最短的数字满足乘以factor,使得原来的最低位等于最高位。#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>using namespace std;int main(){ int base,first,factor; while(cin>>base>>first>>factor) { int 阅读全文
posted @ 2013-06-21 00:28 over_flow 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目:Pseudo-Random Numbers思路:存在循环节,注意开始一部分不一定是循环的#include <cstdio>#include <iostream>#include <algorithm>#include <cmath>#include <cstring>#include <vector>using namespace std;long long z,i,mod,l;long long num[10000000];long long fun(long long x){ return (z*x+i)%mod 阅读全文
posted @ 2013-06-20 20:31 over_flow 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 题目:Uniform Generator思路:因为这样的一个循环的取模总会出现循环节,所以只需要判断step和mod是否互质#include <cstdio>#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <cstdlib>#include <ctime>using namespace std;int step,mod;int gcd(int a,int b){ if(b==0) return a 阅读全文
posted @ 2013-06-20 19:30 over_flow 阅读(195) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页