- 博客(56)
- 资源 (5)
- 收藏
- 关注
原创 439 - Knight Moves
A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboa
2014-11-21 23:01:39
602
原创 705 - Slash Maze
By filling a rectangle with slashes (/) and backslashes ( ), you can generate nice little mazes. Here is an example: As you can see, paths in the maze cannot branch, so the whole maze only cont
2014-11-20 20:46:34
648
原创 784 - Maze Exploration
A maze of rectangular rooms is represented on a two dimensional grid as illustrated in figure 1a. Each point of the grid is represented by a character.
2014-11-20 18:17:32
625
原创 657 - The die is cast
InterGames is a high-tech startup company that specializes in developing technology that allows users to play games over the Internet. A market analysis has alerted them to the fact that games of chan
2014-11-16 17:35:01
576
原创 572 - Oil Deposits
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides th
2014-11-08 16:56:16
579
原创 10562 - Undraw the Trees
Professor Homer has been reported missing. We suspect that his recent research works might have had something to with this. But we really don't know much about what he was working on! The detectives t
2014-11-07 12:24:57
490
原创 839 - Not so Mobile
#include int compute() { int wl,dl,wr,dr; scanf("%d%d%d%d",&wl,&dl,&wr,&dr); if(wl==0) wl=compute(); if(wr==0) wr=compute(); if(wl ==-1 || wr ==-1 || wl*dl!=wr*dr) return -1; return wl+w
2014-11-06 15:54:55
296
原创 327 - Evaluating Simple C Expressions
#include #include #include int main() { int atoz[26],flag[26],i,result,operand,opersign; char expressions[150]; while(fgets(expressions,150,stdin)!=NULL) { printf("Expression: %s",expressions
2014-11-04 14:25:10
347
原创 699 - The Falling Leaves
Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating under the trees. If the same thing ha
2014-11-03 20:04:08
315
原创 712 - S-Trees
#include int main() { int n,order[7],m,index,no=0; char temp[10],leafs[1<<7+1],result[1<<7+1]; while(scanf("%d",&n)==1) { no++; if(n==0) break; for(int i=0;i<n;i++) { scanf("%s",temp);
2014-10-31 14:16:15
359
原创 297 - Quadtrees
A quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadrants. Each quadrant may again be split in four sub q
2014-10-30 21:01:41
362
原创 548 - Tree
#include #include #include using namespace std; struct node { int value; node* lchild; node* rchild; node(int val):value(val){}; }; node* root; int inorder[10000]; int postorder[10000]; int fi
2014-10-28 22:22:00
309
原创 112 - Tree Summing
#include struct node{ int value; struct node *lchild; struct node *rchild; node(int val):value(val){}; }; node* root; void buildTree(node *&root) { char c; int num=0,sign=1,isnum=0; while(scan
2014-10-28 18:55:09
343
原创 10050 - Hartals
#include int main() { int t,n,p; int parties[100]; scanf("%d",&t); for(int index=0;index<t;index++) { int count=0; scanf("%d",&n); scanf("%d",&p); for(int i=0;i<p;i++) scanf("%d",&pa
2014-10-27 19:17:42
343
原创 540 - Team Queue
Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, though it occurs often in everyday life. At lunch time the
2014-10-21 15:01:51
318
原创 11234 - Expressions
#include #include #include #include using namespace std; struct node { char value; node* left; node* right; }; void BFtraverse(node *root,string &output) { queue q; q.push(root); in
2014-10-18 22:26:33
384
原创 11111 - Generalized Matrioshkas
Vladimir worked for years making matrioshkas, those nesting dolls that certainly represent truly Russian craft. A matrioshka is a doll that may be opened in two halves, so that one finds another doll
2014-10-16 12:27:15
361
原创 442 - Matrix Chain Multiplication
Suppose you have to evaluate an expression like A*B*C*D*E where A,B,C,D and E are matrices. Since matrix multiplication is associative, the order in which multiplications are performed is arbitrary. H
2014-10-13 12:30:44
315
原创 673 - Parentheses Balance
#include #include #include using namespace std; int main() { int n,flag; char c; cin>>n; getchar(); for(int i=0;i<n;i++) { flag=1; stack str; while((c=getchar())!='\n') { if(flag==0)
2014-10-12 21:42:17
368
原创 10152 - ShellSort
#include #include int main() { int K,n; char turtles[250][100]; char turtlesTarget[250][100]; scanf("%d",&K); for(int i=0;i<K;i++) { scanf("%d",&n); getchar(); for(int j=0;j<n;j++) f
2014-09-29 17:13:32
344
原创 133 - The Dole Queue
In aserious attempt to downsize (reduce) the dole queue, The New National GreenLabour Rhinoceros Party has decided on the following strategy. Every day alldole applicants will be placed in a large cir
2014-09-28 16:41:07
467
原创 101 - The Blocks Problem
#include #include #include using namespace std; void reset(vector blocks[],int blocksPos[],int a) { while(blocks[blocksPos[a]].back()!=a) { blocks[blocks[blocksPos[a]].back()].push_back(blocks
2014-09-27 21:10:50
282
原创 127 - "Accordian" Patience
#include #include #include #include using namespace::std; int main() { char str[3]; vector > cards; while(scanf("%s",str)) { if(str[0]=='#') break; cards.clear(); stack card; card.pus
2014-09-18 14:33:18
313
原创 123 - Searching Quickly
#include #include #include #include typedef struct { char word[30]; int row,start,end; } KEYWORD; char ignore[50][20]; char titles[250][500]; KEYWORD keywords[3000]; int cmp(const voi
2014-09-12 21:58:52
277
原创 400 - Unix ls
#include #include #include #include int cmp(const void*a,const void*b) { return strcmp((char *)a,(char *)b); } int main() { int N; char lines[100][100]; while(scanf("%d",&N)!=EOF) { for(int i=
2014-09-11 15:55:17
446
原创 340 - Master-Mind Hints
#include #include int main() { int num=0,N,isOver,A,B; int code[1005],codeClone[1005],guess[1005]; while(scanf("%d",&N)!=0) { if(N==0) break; num++; printf("Game %d:\n",num); for(int i=0;i { scanf("%
2014-09-10 16:13:45
356
原创 465 - Overflow
#include #include #include int MaxInt[10]={2,1,4,7,4,8,3,6,4,7}; void tempAdd(int temp[],int product[]) { int i,c=0; for(i=0;i { product[i]=product[i]+temp[i]+c; c=0; if(product[i]>9) {
2014-09-10 16:13:42
328
原创 10106 - Product
#include #include #include void tempAdd(int temp[],int product[]) { int i,j,c=0; for(i=0;i { product[i]=product[i]+temp[i]+c; c=0; if(product[i]>9) { product[i]=product[i] % 10;
2014-09-10 16:13:40
485
原创 424 - Integer Inquiry
#include #include #include int main() { int num[110],sum[110],n=0,c=0,i,j; memset(sum,0,sizeof(sum)); char str[110]; while(1) { memset(num,0,sizeof(num)); scanf("%s",str); int len=st
2014-09-10 16:13:38
325
原创 10115 - Automatic Editing
#include #include int main() { int n,i,tag=0; char find[100][100],replace[100][100],temp[300],*str1,str2[300]; while(1) { scanf("%d",&n); getchar(); if(n!=0) { for(i=0;i { fgets(find[i],100,stdin)
2014-09-10 16:13:36
325
原创 644 - Immediate Decodability
#include #include int main() { char codes[10][12]; char code[12]; int i,j,n=0,set=1,isprint=0; while(scanf("%s",code)==1) { if(code[0]!='9') strcpy(codes[n++],code); else { for(i=0;i for(j=0;j { if
2014-09-10 16:13:34
289
原创 10815 - Andy's First Dictionary
#include #include #include #include int comp(const void *a,const void *b) { return strcmp((char*)a,(char*)b); } #define MAXN 205 char words[50000][MAXN]; int main() { char s[MAXN]; int n=0; int i;
2014-09-10 16:13:32
316
原创 10878 - Decode the tape
#include #include int main() { char s[15]; int i,j,temp=1,num=0; while (fgets(s,15,stdin)!=NULL) { if(s[0]=='_') continue; for(i=9;i>=7;i--)
2014-09-10 16:13:30
448
原创 409 - Excuses, Excuses!
#include #include #include #define MAXN 20+5 char keywords[MAXN][MAXN],excuses[MAXN][75]; int countkey(char e[],int k) { int i,j,m=0,count=0; char temp[75]; for (i=0;i
2014-09-10 16:13:28
382
原创 537 - Artificial Intelligence?
#include #include #include #define MAXN 100+10 char s[MAXN]; void decode_prefix(char s[],double *d) { int i=0; while (isdigit(s[i]) || s[i]=='.') i++; switch(s[i]) { case 'm': *d/=1000; break; case '
2014-09-10 16:13:26
428
原创 10361 - Automatic Poetry
#include #include #define MAXN 100+10 char s1[MAXN],s2[MAXN]; int main() { int i,j,n,b_i,bracket[4]; scanf("%d",&n); getchar(); for(i=0;i { b_i=0; fgets(s1,MAXN,stdin); fgets(s2,MAXN,stdin); for(j=0;
2014-09-10 16:13:23
299
原创 10010 - Where's Waldorf?
#include #include #include char grid[55][55],words[55]; int locate(char s[],int r,int l,int *m,int*n) { int i,j,k,z,east,southeast,south,southwest,west,northwest,north,northeast; for(i=0;i { for(j=0;
2014-09-10 16:13:21
307
原创 401 - Palindromes
#include #include char table[2][21]= { 'A','E','H','I','J','L','M','O','S','T','U','V','W','X','Y','Z','1','2','3','5','8', 'A','3','H','I','L','J','M','O','2','T','U','V','W','X','Y','5','1','S','E',
2014-09-10 16:13:19
359
原创 457 - Linear Cellular Automata
#include #include int population[40]={ 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,1, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0 }; int main() { int n,i,j,k; int dna[10],tmp1[40],tmp2[40]; scanf("%d",&n); f
2014-09-10 16:13:17
514
原创 694 - The Collatz Sequence
#include int collatz( long long m,long long n,int count) { count++; if(m==1) return count; if(m>n) return --count; if(m%2==0) collatz(m/2,n,count); else collatz(m*3+1,n,count); } int main() { long lon
2014-09-10 16:13:15
307
two scoops django best practices 1.5
2014-06-03
Hadoop权威指南 第3版 中文
2016-12-14
python基础教程源码
2014-06-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅