上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 38 下一页
摘要: 优先队列的基本运用……#include #include #include using namespace std; struct Message { char Name[100]; int Data,Priority,index; friend bool ... 阅读全文
posted @ 2014-04-16 16:44 forever97 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 模拟题,学了一下listit=li.erase(it):指向删除后的第一个元素#include #include using namespace std;listli;list::iterator it;int main(){ int cas,n; scanf("%d",&cas); ... 阅读全文
posted @ 2014-04-16 16:20 forever97 阅读(453) 评论(0) 推荐(0) 编辑
摘要: 题解:直接建n个栈,模拟过程即可……#include #include #include using namespace std; int main(){ int n,n2,a,ar[105],cas=1; bool rs[105]; char str[105]; ... 阅读全文
posted @ 2014-04-16 15:59 forever97 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 高一时打过,做了整整一个晚上,现在看到计算器的题目就头疼,从网上找了一个,修修改改了一下……#include #include #include using namespace std;char Precede(char a,char b){ if(a=='+'||a=='-'){ ... 阅读全文
posted @ 2014-04-16 15:46 forever97 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 栈的基本操作……#include #include #include using namespace std;char in[100],out[100];int flag[200];int main(){ int n,top,i,j,k,bo; while(scanf("%d",&n)!... 阅读全文
posted @ 2014-04-16 15:31 forever97 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 题解:栈和队列的基本运用,熟练一下STL。#include #include #include using namespace std;int main(){ int t; scanf("%d",&t); while(t--){ int n,m; str... 阅读全文
posted @ 2014-04-16 15:02 forever97 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目大意:求有n个节点的树有几种? 题解:http://www.cnblogs.com/keam37/p/3639294.html 阅读全文
posted @ 2014-04-16 14:49 forever97 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 题目大意:求n个数的第m中全排列……题解:直接用强大的STL,next_permutation:求序列的下一个排列,还有一种prev_permutation:求上一个全排列……#include #include using namespace std; int main(){ i... 阅读全文
posted @ 2014-04-15 20:49 forever97 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 题目大意:一个长为n的01字符串,使前缀任意0的数量不大于1的数量,求方案数……题解:高一模拟赛时做过,是卡特兰数的几何意义,将字符串变为矩阵寻路,不可越过对角线,那么就是卡特兰数了,C(n+m, n)-C(n+m,n+1)=(n+1-m)(n+m)!/(n+1)!m!。需要注意的是取模的问题,如果... 阅读全文
posted @ 2014-04-15 20:25 forever97 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 题解:因为天平两边都可以放砝码,所以需要再建一个负的砝码值,然后用母函数即可……#include #include using namespace std; int c1[10005],c2[10005],n,sum,res,weight[105]; int main(){ wh... 阅读全文
posted @ 2014-04-13 16:18 forever97 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 系数为1的母函数……#include #include using namespace std; int n,m,size[105][2],c1[105],c2[105]; int main(){ while(scanf("%d%d",&n,&m)!=EOF){ for(int i=1;i<=n;i++)scanf("%d%d",&size[i][0],&size[i][1]); memset(c2,0,sizeof c2); memset(c1,0,sizeof c1); for(int i=size[1][0]. 阅读全文
posted @ 2014-04-13 16:04 forever97 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题目大意:有面值分别为。1,4,9,.......17^2的硬币无数多个。问你组成面值为n的钱的方法数。最简单的母函数模板题:#include #include using namespace std; int c1[305],c2[305],n; int main(){ while(scanf("%d",&n),n){ for(int i=0;i<=n;i++)c1[i]=1,c2[i]=0; for(int i=2;i<18;i++){ for(int j=0;j<=n;j++){ ... 阅读全文
posted @ 2014-04-13 15:58 forever97 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 高斯消元,今天数学死了无数次……#include #include #include #include #include #define LL __int64 const int maxn=55; #define mod 200000000000000003LL //不能用const来定义。。,不知道为什么,需要是素数 #define diff 100000000000000000LL //偏移量,使得数都是整数,方便移位乘法 using namespace std; LL x[maxn], g[maxn][maxn], a[maxn][maxn], b[maxn]... 阅读全文
posted @ 2014-04-13 14:58 forever97 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 题目大意:有一个关于 简单加法表达式 的定义告诉你,就是 选一个数字i 如果 i+(i+1)+(i+2) 它的和,没有任何一位进位的话,那就是 一个i的简单加法表达式,求小于n的表达式数目。题解:排列组合分类讨论即可……#include #include #include using namespace std; char s[15]; int solve(int i,int p){ if(p==1)return s[i]>'2'?3:s[i]-'0'+1; if(s[i]>'3'){return (int)pow(4.0,p-1)* 阅读全文
posted @ 2014-04-13 14:52 forever97 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 彻底对数学绝望了#include #include int flag[1005],p[500],a;int d[100];int init(int s){ int len=0,tmp,h=sqrt(s+0.5); for(int i=0;p[i]1) { if(a%s==0)return -1; d[len++]=s; } return len;}int getans(int x,int s){ int tmp=s/2; __int64 ans=1,b=x; while(tmp>0) { if(tm... 阅读全文
posted @ 2014-04-13 14:26 forever97 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 不会,先搁着……http://blog.csdn.net/acm_cxlove/article/details/7832197 阅读全文
posted @ 2014-04-13 14:09 forever97 阅读(106) 评论(0) 推荐(0) 编辑
摘要: http://wutyyzchangde.blog.163.com/blog/static/172226566201132311311374/#include typedef struct{ __int64 matrix[2][2];}Matrix;__int64 powermod(__int64 ... 阅读全文
posted @ 2014-04-13 13:59 forever97 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 数学实在是差到不行了……#include #include #include #include #include using namespace std; #define LL __int64 const LL maxn=1001; LL e[maxn],t; LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);} LL euler_phi(LL n)//求单个欧拉函数 { LL m=(LL)sqrt(n+0.5); LL i,ans=n; for(i=2;i1)ans=ans/n*(n-1); ... 阅读全文
posted @ 2014-04-13 13:53 forever97 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题解:不互质的中国剩余定理#include #include #define ll long long#define maxn 10using namespace std;ll c[maxn],m[maxn],n,am,ac,y0,z0,d;bool ans;void exgcd(ll a,ll b,ll& d,ll& x,ll& y){ if (b==0) { d=a,x=1,y=0; } else exgcd(b,a%b,d,y,x),y-=x*(a/b); }int main(){ ll i,t,cas=0; scanf("%I64d",&am 阅读全文
posted @ 2014-04-13 13:32 forever97 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 题目大意:对一个长度为n(n #include using namespace std;const int MAXN=50005;int c[105][MAXN],begin[MAXN],n,m;void update(int k,int x,int val){while(x<=n)c[k][x]+=val,x+=x&-x;}int getsum(int pos){ int s=0; for(int i=1;i<=10;i++){ int k=10*(i-1)+pos%i,x=pos; while(x)s+=c[k][x],x-=x&-x; }re... 阅读全文
posted @ 2014-04-09 14:50 forever97 阅读(137) 评论(0) 推荐(0) 编辑
上一页 1 ··· 23 24 25 26 27 28 29 30 31 ··· 38 下一页