- 博客(115)
- 收藏
- 关注
原创 vc6.0下创建xml文档
#include //此处使用MFC类,工程->常规 设置为 Use MFC in a Static Library#import//using namespace MSXML2;int main(){ ::CoInitialize(NULL); MSXML2::IXMLDOMDocumentPtr XMLDOC;//创建文档 MSXML2::IXMLDOMElementPtr
2015-07-30 15:47:51
537
原创 错排
题目 http://www.jobdu.com/link.php?url=http://ac.jobdu.com错排公式 f(n) = (n-1)[f(n-2)+f(n-1)] (n>2) #includeint main(){ int n; long long f[21]; while(scanf("%d",&n)!=EOF){ f[0]=f[1]=0; f[2]=1;
2015-03-09 21:18:25
476
原创 字典序输出全排列
#includeint n,sum=0,list[5]={5,4,3,2,1};void swap(int a,int b){ int temp=list[a]; list[a]=list[b]; list[b]=temp;}void move(int a,int b){ int temp=list[b]; for(int i=b;i<a;i++) list[i]=list[
2015-03-08 11:42:33
705
原创 题目1477:怪异的洗牌
题目 http://ac.jobdu.com/problem.php?pid=1477#includevoid move(int n,int x,int a[],int b[]){ int pos=0,i; if(x<=n/2){ for(i=n/2+x;i>=x+1;i--) b[++pos]=a[i]; for(i=
2015-03-03 22:43:49
420
原创 输出全排列
#includeint sum=0;void dfs(int n,int pos,int list[]){ if(pos<2){ sum++; for(int i=1;i<=n;i++) printf("%d ",list[i]); printf("\n"); return; } for(int i=pos;i>=1;i--){ int temp=list[po
2015-03-03 22:39:31
468
原创 字符串枚举(14复试)
已知集合S={‘A’,’B’,’C’},输入数字n,要求输出所有满足条件的字符串:长度为n,字符串的每个字符都是集合S的元素#includeint sum=0;void dfs(int n,int pos,char str[]){ if(pos>=n){ str[n]='\0'; sum++; printf("%s\n",str); return; } str[pos
2015-03-03 22:38:18
545
原创 交大机试(分解质因数)
题目 http://ac.jobdu.com/problem.php?pid=1104#includeint min(int a,int b){ if(a<b) return a; return b;}int prime(int k,int n){ int sum=0,ii; for(int i=k;i<=n;i++){ i
2015-03-03 22:35:17
610
原创 阶乘末尾0的个数(分解质因数)
#includeint main(){ int n; scanf("%d",&n); if(n<5){ printf("0\n"); return 0; } int sum=0,k; for(int i=5;i<=n;i++){ k=i; while(k%5==0){ sum++; k/=5; } } printf("%d\n",sum); re
2015-03-03 22:33:33
679
原创 题目1466:排列与二进制(机试2010)
#includeint judge(int k){ int sum=0; while(k%2==0){ sum++; k/=2; } return sum;}int main(){ int n,m; while(scanf("%d%d",&n,&m)&&n!=0){ int sum=0;
2015-03-03 22:32:24
386
原创 链表
#include#include#includetypedef struct LNode{ int data; LNode *next;}LNode,*LinkList;bool is_prime(int k){ for(int i=2;i<=(int)sqrt((double)k);i++){ if(k%i==0) return false; } return tr
2015-03-03 22:28:00
486
原创 sdut 2624 Contest Print Server (第四届省赛)
#include#include#includeusing namespace std;int main(){ int t; scanf("%d",&t); while(t--){ int n,s,x,y,mod; char name[20],nouse[20]; int page,ppage; int counter=0; scanf("%d%d%d%d%d",
2014-05-09 21:32:51
577
原创 NYOJ15 括号匹配(二)
题目链接 http://acm.nyist.net/JudgeOnline/problem.php?pid=15#include#include#includeusing namespace std;int dp[105][105];char a[105];int main(){ int n; scanf("%d",&n); while(n--){ scanf("%s",a)
2014-05-04 18:44:49
528
原创 poj 1067 取石子游戏
裸威佐夫博弈#include#include#includeusing namespace std;const double key=(sqrt(5.0)+1.0)/2;int main(){ int a,b,k; while(scanf("%d%d",&a,&b)==2){ if(a>b){ a^=b;b^=a;a^=b; } k=b-a; if(floor(
2014-05-04 15:19:49
517
原创 SDACM 五一联赛 3 G - L
#include#include#include#include#define inf 0x3f3f3f3fusing namespace std;int ma[1010][1010];int cost[1010],a[1010]; int n,m;void init(){ for(int i=1;i<=n;i++){ for(int j=1;j<i;j++) ma[
2014-05-03 23:55:59
868
原创 sdut2408 Pick apples(山东第三届省赛)
#include#include#includeusing namespace std;int dp[1000005];int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int lcm(int a,int b){ return a/gcd(a,b)*b;}int main(){ int
2014-05-02 23:30:03
519
原创 sdut2415 Chess (山东第三届省赛)
#include#include#include#include#define N 100005using namespace std;struct node{ int x,y; int p; int pos;}x[N],y[N],x_y[N],xy[N],xxy[N],xyy[N],x_yy[N],xx_y[N];int hited[N];bool cmpxxy(node
2014-05-02 23:24:50
772
原创 sdut 2170 The Largest SCC(山东第二届省赛)
#include#include#include#define N 1005#define M 20005using namespace std;struct node{ int to,next;}edge[M];int head[N],tot;int dfn[N],low[N],stap[N],belong[N];bool instack[N];int indexx
2014-04-25 18:14:41
639
原创 poj 1236 Network of Schools
#include#include#include#define N 110#define M 5010using namespace std;struct node{ int to,next;}edge[M];int head[N],tot;int dfn[N],low[N],stap[N],belong[N];int in[N],out[N];bool instac
2014-04-22 19:01:14
451
原创 poj 2762 Going from u to v or from v to u?
tarjan算法学习 https://www.byvoid.com/blog/scc-tarjan/
2014-04-22 18:59:50
623
原创 hdu 4739 Zhuge Liang's Mines
#include#include#include#include#includeusing namespace std;struct node{ int x,y;}a[22];vector mine;int dp[(1<<20)+2];int n;bool cmp(node a,node b){ if(a.x==b.x) return a.y
2014-04-21 18:30:20
582
原创 poj 3624 01背包 水
水#include#includeusing namespace std;int dp[12890]={0};int main(){ int n,m; int w,d; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++){ scanf("%d%d",&w,&d); for(int j=m;j>=w;j--) if(dp[j-w]+
2014-04-16 14:28:39
413
原创 poj 1948 Triangular Pastures
#include#include#include#includeusing namespace std;bool dp[45][800][800];int a[45];int main(){ int n,i,j,k; int total=0; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&a[i]); total+=a[
2014-04-14 19:53:15
508
原创 hdu4003 Find Metal Mineral
#include#include#include#define M 10010using namespace std;struct node{ int to,val,next;}edge[M*2];int head[M],tot;int dp[M][11],cost[M];int n,s,k;void insert(int u,int v,int val){ e
2013-09-09 13:48:53
524
原创 hdu4705 Y
非连通组合个数=所有组合-连通组合个数树形DP,根结点表示三个连通组合数的中间那个数#include#include#includeusing namespace std;#define M 100010#pragma comment(linker, "/STACK:16777216")struct node{ int v,next;}edge[M*2];int hea
2013-09-07 20:26:45
764
原创 hdu1561 The more, The Better hdu1011 Starship Troopers
两道相似的树形dp+有依赖的的背包,有依赖的背包的多层依赖关系可以用树表示出来,所以以后遇到多层依赖关系的背包可以考虑将依赖关系表示成一棵树,然后树形DP求解,有依赖的背包的求解使用到分组背包思想,详见背包九讲相关专题#include#include#include#define M 210using namespace std;int n,m;int head[M];struct
2013-09-07 20:09:16
577
原创 hdu2196 Computer
求树的所有结点的最长直径#include#include#includeusing namespace std;#define M 10010int len[M],len2[M],leaf[M],leaf2[M],head[M];int n,tot;struct node{ int to,dis,next;}edge[M*2];void insert(int u,int
2013-09-07 20:00:00
637
原创 hdu4514 湫湫系列故事——设计风景线
求树的最长直径,之前做过hdu2196,套用那道题的思路,两次dfs,求出每个结点的最长直径,然后找出最大的即为整棵树的最长直径#pragma comment(linker, "/STACK:102400000,102400000")#include#include#include#define M 100010#define ME 1000010using namespace std
2013-09-07 19:46:30
799
原创 hdu2078
看完题就往类背包DP上想了,看了discuss才意识到这题根本没那么麻烦#include#includeusing namespace std;int main(){ int t; int n,m; int a; scanf("%d",&t); while(t--){ int minn=105; scanf("%d%
2013-08-07 15:08:12
747
原创 pygame.event.get()
刚学习python+pygame就遇到了个棘手的问题——pygame.event.get()这是官方注释pygame.event.get()get events from the queueget() -> Eventlistget(type) -> Eventlistget(typelist) -> EventlistThis wi
2013-07-28 15:36:56
19490
1
转载 Python完全新手教程
作者:taowen, billriceLesson 1 准备好学习Python的环境下载的地址是:www.python.org为了大家的方便,我在校内作了copy:http://10.1.204.2/tool/compiler&IDE/Python-2.3.2-1.exelinux版本的我就不说了,因为如果你能够使用linux并安装好说明你可以一切自己搞定的。运
2013-07-21 16:41:49
768
原创 sdut2404 Super Prime
输出有时候是YES NO,有时候是Yes No,有时候是yes no。因为这个WA实在可惜,Be careful !#include#include#include#includeusing namespace std;#define M 100000bool mark[M+5],issuper[M+5];int su[M+5];int k;void prime(){
2013-06-07 21:46:09
703
原创 hdu2844 Coins
在discuss里看到的这个方法,不需要二进制优化,也不需要单调队列优化,仅需增加一个数组记录每个coin使用的个数,既好写有好理解,话说那个高端大气的单调队列优化各种复杂抽象难以理解,膜拜ing。#include#include#includeusing namespace std;int n,m;int a[105],c[105],used[100010];bool f[1
2013-06-07 10:42:44
553
原创 hdu3415 Max Sum of Max-K-sub-sequence
我的第一道单调队列题目,之前有看过这道题的题解,并简单了解了单调队列,本以为自己能独立写出来,战战兢兢写完,一调试果然是错的,找到了原因还是不知道该如何解决,无奈再看题解,队列里存的是数组下标,我存的是元素自身,这样就不能维护子序列的长度,显然是错的。总结:菜鸟智力是硬伤,还有很长的路要走。#include#include#includeusing namespace std;in
2013-06-06 23:43:31
629
原创 hdu3555 Bomb 数位DP
数位DP初学者,代码就是网上千篇一律,相似度极高的数位DP代码一个不错的题解http://www.cnblogs.com/luyi0619/archive/2011/04/29/2033117.html#include#include#include#define llong long longusing namespace std;llong dp[20][3];int
2013-06-03 22:35:34
555
转载 C/C++的64位整型
转自http://www.byvoid.com/blog/c-int64/C/C++的64位整型在C/C++中,64为整型一直是一种没有确定规范的数据类型。现今主流的编译器中,对64为整型的支持也是标准不一,形态各异。一般来说,64位整型的定义方式有long long和__int64两种(VC还支持_int64),而输出到标准输出方式有printf("%lld",a),prin
2013-06-02 15:24:43
605
原创 a^b^c%1000000007(高阶幂取模&&费马小定理)
#include#include#include#define llong long longusing namespace std;llong a,b,c,p;llong powi(llong a,llong b,llong p){ llong c=1; while(b>0){ if(b%2==1){ c=c*a%p; b--; } else{ a=
2013-06-02 15:18:00
1819
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人