上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 18 下一页
摘要: 好高兴 一上午做了2个题 题意:求素因子只有2 3 5 7 数 约束的个数 我用的时搜索计数法 感觉还应该有比较不错的组合数学方法#includeusing namespace std;__int64 dmax;int prime[4];void dfs(int t){ if(t>=4) { ... 阅读全文
posted @ 2014-04-29 11:47 _一千零一夜 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 第一次打表一言难尽 注意表的范围 因为打表 数组长度不好计算算 要有个结尾标志#includeusing namespace std;int prime[1000]={5,7,11,101,131,151,181,191,313,353,373,383,727,757,787,797,919,9... 阅读全文
posted @ 2014-04-29 10:53 _一千零一夜 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 没说的 暴力打表#include#includeusing namespace std;int a[62768];int b[42768];int prime[42768];int main(){ int n=0,j,i; memset(b,0,sizeof(b)); memset... 阅读全文
posted @ 2014-04-28 21:43 _一千零一夜 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 典型的快速幂成应用题意:求x 使得x^e%n=num#includeusing namespace std;bool funtion(int x,int e,int n,int num){// m^n % k int b = 1; while (e > 0) { i... 阅读全文
posted @ 2014-04-28 20:59 _一千零一夜 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题意:求N!中末尾0的个数 其实就是5的个数 因为2*5=10 肯定n中2的个数比5的个数多#includeusing namespace std;int main(){ int n; int t,d; int sum; scanf("%d",&t); while(t... 阅读全文
posted @ 2014-04-28 20:03 _一千零一夜 阅读(97) 评论(0) 推荐(0) 编辑
摘要: % mod 比较基本的广搜 有些数论知识 第一次在节点力用了队列 挺好#include#includeusing namespace std;struct Node{ int x; int step; queue q;};int v[1000010];int n,m,k;bool bfs(){ int s=((n+1)%k+k)%k; queueq; Node now,next; now.x=n;now.step=0; q.push(now); memset(v,0,sizeof(v)); while(!q.empty()) {... 阅读全文
posted @ 2014-04-28 17:48 _一千零一夜 阅读(83) 评论(0) 推荐(0) 编辑
摘要: /**中国剩余定理(不互质)*/#include #include #include using namespace std;typedef __int64 int64;int64 Mod;int64 gcd(int64 a, int64 b){ if(b==0) return a; return gcd(b,a%b);}int64 Extend_Euclid(int64 a, int64 b, int64&x, int64& y){ if(b==0) { x=1,y=0; return a; } int64 d = Extend_Euclid(b,a%b,x,y); int6 阅读全文
posted @ 2014-04-26 19:36 _一千零一夜 阅读(628) 评论(0) 推荐(0) 编辑
摘要: 一下午 终于行了基本的容斥定理收藏 2314291容斥原理编辑在计数时,必须注意无一重复,无一遗漏。为了使重叠部分不被重复计算,人们研究出一种新的计数方法,这种方法的基本思想是:先不考虑重叠的情况,把包含于某内容中的所有对象的数目先计算出来,然后再把计数时重复计算的数目排斥出去,使得计算的结果既无遗漏又无重复,这种计数的方法称为容斥原理。目录1公式2严格证明3原理1▪ 分析 ▪ 答案 ▪ 试一试 4原理2▪ 例1 ▪ 例2 ▪ 例3 ▪ 例4 ▪ 例5 1公式编辑也可表示为设S为有限集,,则#includeint a[12];__int64 n;__int64 sum;int m;__int6 阅读全文
posted @ 2014-04-26 19:10 _一千零一夜 阅读(85) 评论(0) 推荐(0) 编辑
摘要: #include #include#include#include#include#includeusing namespace std;#define N 1010#define INF 0 xfffffff#define LL long longLL dp[1010];LL sum[1010];int a[1010];int min(int a,int b){ if(a>t; while(t--) { memset(sum,0,sizeof(sum)); cin>>n>>m; // for(i = 1 ;i >a[i]; sum[i] = sum[i-1 阅读全文
posted @ 2014-04-24 14:40 _一千零一夜 阅读(122) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;__int64 f(__int64 a,__int64 b){ __int64 t; __int64 sum=a*b; if(a<b) { t=a; a=b; b=t; } while(b) { t=a%b; a=b; b=t; } return sum/a;}int main(){ int t,n; __int64 x; __int64 lcm; scanf("%d",&t); while(t--) { scanf("%d",&n); scanf("%I64d&qu 阅读全文
posted @ 2014-04-22 18:34 _一千零一夜 阅读(90) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 18 下一页