上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: 题意:给你n堆石头,每次只能在一堆取最少一个石子,最后拿走最后一堆的为胜者,问胜者有多少种赢得取法#include #includeusing namespace std;int main(int argc, char** argv) { int n,stone[1010],i,t; while(scanf("%d",&n)!=EOF,n){ t=0; for(i=0;i<n;i++){ scanf("%d",&stone[i]); t^=stone[i]; } int sum=0; for(i=0;i<n;i++) if(( 阅读全文
posted @ 2013-10-26 23:18 Teemo的技术blog 阅读(168) 评论(0) 推荐(0)
摘要: Nim游戏的概述:还记得这个游戏吗?给出n列珍珠,两人轮流取珍珠,每次在某一列中取至少1颗珍珠,但不能在两列中取。最后拿光珍珠的人输。后来,在一份资料上看到,这种游戏称为“拈(Nim)”。据说,它源自中国,经由被贩卖到美洲的奴工们外传。辛苦的工人们,在工作闲暇之余,用石头玩游戏以排遣寂寞。后来流传到高级人士,则用便士(Pennies),在酒吧柜台上玩。最有名的玩法,是把十二枚便士放成3、4、5三列,拿光铜板的人赢。后来,大家发现,先取的人只要在3那列里取走2枚,变成了1、4、5,就能稳操胜券了,游戏也就变得无趣了。于是大家就增加列数,增加铜板的数量,这样就让人们有了毫无规律的感觉,不易于把握。 阅读全文
posted @ 2013-10-26 23:13 Teemo的技术blog 阅读(197) 评论(0) 推荐(0)
摘要: 题意:给你n个堆数据,每堆有六个数,堆与堆之间要顺时针或逆时针相等,问是否有两堆相等哈希直接算了。#include #include #includeusing namespace std;#define N 1200010struct node{ int num[6]; int next;}p[N];int cur ,hashTable[N];void initHash(){ cur=0; memset(hashTable,-1,sizeof(hashTable));} int getHash(int *num){ int hash=0; for(int i=0;i<6;i++) ha 阅读全文
posted @ 2013-10-26 21:46 Teemo的技术blog 阅读(119) 评论(0) 推荐(0)
摘要: #include #include#include#includeusing namespace std; #define INF 0xfffffff #define N 210 int cap[N][N],flow[N][N]; int pre[N],dist[N]; int ek(int sta,int end){ int i,curr,sum=0; memset(flow,0,sizeof(flow)); while(1){ memset(pre,0,sizeof(pre)); memset(dist,0,sizeof(dist)); queue q; q.push... 阅读全文
posted @ 2013-09-24 22:56 Teemo的技术blog 阅读(105) 评论(0) 推荐(0)
摘要: #include#include#include#includeusing namespace std;#define INF 0xfffffff#define mMax 1010#define nMax 110int cap[nMax][nMax],flow[nMax][nMax];int pre[nMax],dist[nMax];int Edmonds_Karp(int sta,int end){ int i,curr,max=0; memset(flow,0,sizeof(flow)); while(1){ memset(pre,0,sizeof(pre)); memset(dist.. 阅读全文
posted @ 2013-09-23 22:58 Teemo的技术blog 阅读(90) 评论(0) 推荐(0)
摘要: 用mount命令加载iso到虚拟光驱先在/media/目录下新建一个空目录作为加载iso的虚拟光驱名称:sudo mkdir /media/aaaa再用mount挂载:sudo mount -o loop /media/sda9/down/[CCTV-大国崛起].DVD_1.iso /media/aaaa 阅读全文
posted @ 2013-09-02 22:20 Teemo的技术blog 阅读(108) 评论(0) 推荐(0)
摘要: 题意:给你n个单词,再给你一串字符,求在字符中有多少个单词出现过#include #include#includeusing namespace std;#define N 10010#define MAXLEN 1000010struct node{ node *child[26]; node *fail; int count; void init(){ for(int i=0;ichild[t]!=NULL) now=now->child[t]; else{ next=new node; next->init(); now->child[t]=next; now=n... 阅读全文
posted @ 2013-08-19 00:07 Teemo的技术blog 阅读(98) 评论(0) 推荐(0)
摘要: #include #include#includeusing namespace std; #define N 400010/* run this program using the console pauser or add your own getch, system("pause") or input loop */int ch[N][30];int val[N];int cnt;char str[N];int d[N];int idx(int c){ return c-'a';}void insert(char *s){ int i,n=strlen 阅读全文
posted @ 2013-08-18 17:19 Teemo的技术blog 阅读(131) 评论(0) 推荐(0)
摘要: poj终于到100题,贴个代码纪念一下,hdu 到400题再贴题意:有20个城市,接下来有19行告诉你,i城市与n个城市相连,图是双向的,然后叫你求x到y的最小经过几个城市#include #include#include#includeusing namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */#define N 210#define INF 0xffffffint num;struct nod 阅读全文
posted @ 2013-08-04 19:51 Teemo的技术blog 阅读(112) 评论(0) 推荐(0)
摘要: 题意:是否唯一确定顺序,根据情况输出#include #include#include#includeusing namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */#define N 30int n,m;int map[N][N],indegree[N],list[N];int toposort(int n){ int in[N],flag,t,num; memcpy(in,indegree,siz 阅读全文
posted @ 2013-07-31 15:44 Teemo的技术blog 阅读(147) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 下一页