自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(42)
  • 收藏
  • 关注

原创 hdu 1427 24点暴力dfs

点击打开链接#include #include #include using namespace std;int num;int a[4],x;const int inf=1<<10; // 括号改变的运算符的优先级所以 //a@b@c@d 符号的全排列有 3!种可能 由于数字可以调换 ((a@b)@c) @d 等价于 a @ ((b@c)@d

2016-05-31 20:46:04 787

原创 poj 1222 经典枚举

点击打开链接#include #include #include using namespace std;const int M=8;int g[M][M],button[M][M];bool solve(){ int i,j,k; for(i=1;i<5;i++) //根据第i行的state 确定第i+1行的state { for(j=1;j<=6;j++) {

2016-05-30 17:30:35 328

原创 poj 1190 dfs+剪枝

点击打开链接http://poj.org/problem?id=1190#include #include #include #define M1 30using namespace std; //Q=Sπ求最小S->外表面最小 = (侧面积面积+底面积(中间部分都投影到底面))最小 int MinA[M1]; //i层 cake的最小表面积 int MinV[M1];i

2016-05-29 19:04:53 260

原创 poj 1011 经典的剪枝

点击打开链接#include #include #include #include using namespace std;const int M=1100;vector p;int n,L,len,flag,last,used[M];bool cmp(int a,int b){ return a>b;}int dfs(int cur,int l){ if(cur=

2016-05-28 17:44:39 332

原创 poj 3614 贪心

点击打开链接#include #include #include #include const int M=3110;using namespace std;typedef pair P;P cow[M],lotion[M];priority_queue,greater > q;int main(){ int c,l; cin>>c>>l; for(int i=0;

2016-05-28 15:42:55 267

原创 poj 1061 exgcd解同余方程

点击打开链接http://poj.org/problem?id=1061#include #include using namespace std;__int64 t,p,d;void exgcd(__int64 a,__int64 b){ if(b==0) { t=1; p=0; d=a;//gcd } else { exgcd(b,a%b); __i

2016-05-27 15:41:47 520

原创 poj 3255次短路(暴力法)

点击打开链接http://poj.org/problem?id=3255#include #include #include #include #include #include #define M 5010#define Me 200005const int Inf=1000001000;using namespace std;struct edge{

2016-05-26 20:40:07 361

原创 nyoj 扩展欧几里德入门

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=775百度有证明 求解 x,y的方法的理解设 a>b。1,显然当 b=0,gcd(a,b)=a。此时 x=1,y=0;2,a>b>0 时设 ax1+ by1= gcd(a,b);bx2+ (a mod b)y2= gcd(b,a mod

2016-05-26 15:06:53 356

原创 poj 1328 贪心经典

点击打开链接http://poj.org/problem?id=1328#include #include #include #include #define M 1110using namespace std;int n;double r;typedef struct{ double l; double r;}Num;Num num[M];bool cmp(Num a,

2016-05-25 20:12:27 415

原创 poj 3104 二分枚举答案,最值问题转化为判定性问题

点击打开链接http://poj.org/problem?id=3104#include #include #include #include #define M 101000using namespace std;__int64 a[M],n,k;bool check(__int64 time) // 贪心->判定时间 x是否可行 { // 把洗衣机留给之x时间

2016-05-25 12:44:49 422

原创 hdu5695 贪心+拓扑排序

点击打开链接#include #include #include #include #include #define M 100010using namespace std;int in[M];vectorv[M]; //出度 priority_queueq;int main(){ int t; long i,k,n,m,a,b; __int64 ans; cin

2016-05-23 18:14:13 341

原创 nyoj 69

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=69#include #include #include #define M 1000010using namespace std;double figer[M];int main(){ long t,i,j,k,n; figer[1]=1; for(i=2;i l

2016-05-23 17:13:43 309

原创 poj 2431 贪心+优先队列

点击打开链接http://poj.org/problem?id=2431#include #include #include #include #include #define M 10100using namespace std;typedef struct{ int a; //加油站距离起点 int b; //油量 }Gas;Gas s[M];int l,p,n;

2016-05-22 19:24:39 348

原创 poj 3069贪心~

点击打开链接http://poj.org/problem?id=3069#include #include #define M 1010using namespace std;int a[M];int main(){ int r,n,i,j,k,ans; while(1) { cin>>r>>n; if(n==-1&&r==-1) { break; }

2016-05-22 17:56:02 281

原创 nyoj 37 LCS

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=37#include #include #include #define M 1010using namespace std;int dp[M][M];char s[M],rs[M];int main(){ int t,n,i,j,k,ans; cin>>t; w

2016-05-21 19:39:45 277

原创 poj 3617贪心

点击打开链接#include #define M 2100using namespace std;int main(){ char str[M][1],s[M]; int n,i,f,l,k,a,b; cin>>n; for(i=1;i<=n;i++) { cin>>str[i]; } k=0; f=1;l=n; while(k<n) { a=f; b=l;

2016-05-21 18:38:09 257

原创 poj 1852 ants 思维题

点击打开链接http://poj.org/problem?id=1852#include #include #include #include using namespace std;const int M=101000;int a[M];int main()//每个ant的最晚掉落时间 (如果两只蚂蚁碰到会改变方向) { //A L , B, R -> A R

2016-05-21 17:38:17 311

原创 nyoj 860 (01背包 变形)

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=860#include #include #include #define Inf 1001000000 using namespace std; const int M=110; // 因为同样价值,重量越小,那么最后能装的价值就可能越大long dp[M][M*M

2016-05-20 20:48:00 265

原创 hdu 2141 枚举后 二分查找

点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=2141#include #include using namespace std;const int M=1010;__int64 S[M*M],A[M],B[M],C[M],x,flag,k,t;int BS(__int64 key){ __int64 l=1,r=k,mid;

2016-05-19 18:08:06 392

原创 hdu 1556 树状数组(区间更新,单点求和)

http://acm.hdu.edu.cn/showproblem.php?pid=1556#include #include #define M 110000int c[M],n;int Lowbit(int x){ return x&(-x);}void Add(int x,int d) // 1~x内的所有小区间个数 加 1 (更新区间) { while(x)

2016-05-19 16:51:00 303

原创 poj 2481 树状数组

点击打开链接http://poj.org/problem?id=2481#include #include #include using namespace std;const int M=110000;typedef struct{ int x; int y; int id; int lar;}Cow;Cow cow[M],tmp; int c[M]; // c[i]

2016-05-18 20:25:20 423

原创 poj 2182

点击打开链接http://poj.org/problem?id=2182#include #include const int M=8010;int a[M],b[M],visit[M];int main(){ int n,i,j,k,min=1; memset(visit,0,sizeof(visit)); scanf("%d",&n); for(i=1;i<=n-1;i+

2016-05-17 19:09:59 310

原创 hdu 1541 树状数组入门

点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1541#include #include #include const int M=32100;int c[M],degree[M],n;int Lowbit(int x){ return x&(-x);}void Add(int x,int d) // { while(x<

2016-05-16 12:39:17 316

原创 nyoj 522 树状数组入门

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=522#include #include const long M=100001;long c[2*M+10]; // c[i]=x 以端点 i为尾(i-lowbit(i)+1~~i)长度为 Lowbit(i)的线段出现过 x次 long m,n;long

2016-05-15 15:03:11 270

原创 POJ 3368 RMQ

http://poj.org/problem?id=3368#include #include #include #include const int M=100010; // num[i] 位置i所在段 value[i],count[i] 第i段的值和出现次数 long k,n,a[M],num[M],value[M],count[M],left[M],right[M]; /

2016-05-14 14:55:51 339

原创 2016百度之星选拔 1002 递推和大数加法

http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=690&pid=1002#include #include #include #include using namespace std;const int M=201;int f[M][500];void Add(int x,int y){ int

2016-05-14 14:00:09 447

原创 2016百度之星 热身1004

http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=695&pid=1004#include #include int main() //正多边形为偶数 所以 如果先手能在中间放 则不管后手在哪里放 先手都能放在其关于中心点(第一个圆的圆心)对称的位置 { int t,i; double n,a

2016-05-13 19:49:07 384

原创 hdu 3555 数位dp

http://acm.hdu.edu.cn/showproblem.php?pid=3555#include #define M 25__int64 dp[M][3]; //dp[i][0] 位数为i 不含49的个数 //dp[i][1] 位数为i 不含49的个数 但是尾数为9 //dp[i][2] 位数为i 含49的个数 int num[M]; int mai

2016-05-11 20:46:37 299

原创 nyoj 115 dijkstra

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=115#include #include const int M=1010;int dist[M],s[M],g[M][M];int main(){ int t,i,j,k,a,b,n,m,p,q,c[M]; scanf("%d",&t); while(t--) {

2016-05-11 19:07:43 291

原创 2016百度之星热身 1001 递推

http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=695&pid=1001#include const int M=1000010;__int64 dp[M];int main() // 题意:要想使第三次搬家和第一次搬家一样 { //则 第二次搬家的结果和没搬家之前的状态一定是一样的

2016-05-11 12:29:16 292

原创 hdu 2089

http://acm.hdu.edu.cn/showproblem.php?pid=2089#include const int M=101000;int dp[M];// 前i个数字中 unlucky num个数 int fun(int x){ int a[M],i,j,k; i=0; while(x) { if(x%10==4) return 1; if(x%

2016-05-10 20:05:55 277

原创 nyoj 722 Sudoku (暴力搜索)

点击打开链接http://acm.nyist.net/JudgeOnline/problem.php?pid=722#include #define M 10int g[M][M],flag;int check(int x,int y,int num){ int i,j,a,b; a=(x/3)*3; //算出所处9宫格的第一个位置 b=(y/3)*3; for(i=a;i

2016-05-10 13:16:17 359

原创 hdu 1232 并查集

点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1232#include #define M 1010int par[M];int find(int x){ int k,t,y; k=x; while(par[x]!=x) { x=par[x]; } while(k!=x) //路径压缩 { // 把所

2016-05-09 19:15:30 265

原创 hdu 5676 dfs打表

http://acm.hdu.edu.cn/showproblem.php?pid=5676#include #include using namespace std;#define M 100000000__int64 table[M],k=0;void dfs(int p4,int p7,__int64 s) //用dfs打表 { if(p4+p7<=18&&p4<=9&&p

2016-05-07 16:33:22 379

原创 nyoj 38 Prim裸题

http://acm.nyist.net/JudgeOnline/problem.php?pid=38#include #include #define M 610int g[M][M],dist[M];int main(){ int t,i,j,k,v,e,a,b,c,min,ans; scanf("%d",&t); while(t--) { memset(g,

2016-05-07 15:41:50 543

原创 nyoj 104 To the Max

http://acm.nyist.net/JudgeOnline/problem.php?pid=104#include #include #define M 110 //(i,j)看成常数后 枚举i,j int w[M][M],dp[M];// dp[k] 从第i行到第j行 以第k列结尾的最大子矩阵 int main(){ int t,r,c,i,j,k,a[M][M],max

2016-05-07 13:32:33 472

原创 nyoj 23 Bash Game

http://acm.nyist.net/JudgeOnline/problem.php?pid=23#include int main(){ long m,n,r; int t; scanf("%d",&t); //题目 两人轮流抽一堆物品共n个 每次至少抽一个最多抽m个 :Winner为先抽完的人 while(t--) //当剩下m+1时 不管先手的怎么抽都是输

2016-05-07 12:41:08 273

原创 hdu 2099

http://acm.hdu.edu.cn/showproblem.php?pid=2099#include int main(){ int i,j; long n,a,b,x,y; while(scanf("%ld%ld",&a,&b)&&(a+b)) { x=a; n=0; for(i=0;i<=9;i++) //枚举个位 { for(j=0;j<

2016-05-06 16:09:28 372

原创 nyoj 素数环

#include #include #define M 21int flag,visit[M],Prime[M+M],n,ans[M]; void dfs(int cur){ int i,j,k; if(cur==n+1) { if(Prime[ans[cur-1]+1]) // 最后一个和头一个也是素数则成立 { flag=1; for(i=1;i<=

2016-05-05 15:50:11 308

原创 zoj 2886

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2886#include #include #define M 11000int main(){ int t,n,s,i,j,k,c; char str[M]; scanf("%d",&t); while(t--) { scanf("%s",str)

2016-05-04 13:06:32 373

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除