摘要: 题解:因为天平两边都可以放砝码,所以需要再建一个负的砝码值,然后用母函数即可……#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) 编辑