uva
文章平均质量分 57
xj_347
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
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 阅读 · 0 评论 -
537 - Artificial Intelligence?
#include#include#include#define MAXN100+10chars[MAXN];voiddecode_prefix(char s[],double *d){inti=0;while(isdigit(s[i]) || s[i]=='.') i++;switch(s[i]){case 'm':*d/=1000; break;case '原创 2014-09-10 16:13:26 · 428 阅读 · 0 评论 -
673 - Parentheses Balance
#include#include#includeusing 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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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;ifor(j=0;j{if原创 2014-09-10 16:13:34 · 289 阅读 · 0 评论 -
112 - Tree Summing
#includestruct 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 阅读 · 0 评论 -
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 · 313 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
414 - Machined Surfaces
#include#include#define MAXN 100int main(){ int i,j,count,k,min,res; char s[30]; int array[15]; while(scanf("%d",&k)&&k) { getchar();//读入scanf遗留的'\n',清空输入缓存 res=0; for (i=0;i {原创 2014-09-10 16:13:04 · 287 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
11234 - Expressions
#include#include#include#includeusing 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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
458 - The Decoder
#include#includechar s[1000];int main(){ int n,i; while (scanf("%s",s)!=EOF) { n=strlen(s); for(i=0;i { printf("%c",s[i]-7); } printf("\n"); } return 0;} uva.onlinejudge.org原创 2014-09-10 16:13:00 · 267 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
10361 - Automatic Poetry
#include#include#define MAXN100+10chars1[MAXN],s2[MAXN];intmain(){inti,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 阅读 · 0 评论 -
10815 - Andy's First Dictionary
#include#include#include#includeint comp(const void *a,const void *b){ return strcmp((char*)a,(char*)b);}#define MAXN 205char words[50000][MAXN];int main(){ char s[MAXN]; int n=0; int i;原创 2014-09-10 16:13:32 · 316 阅读 · 0 评论 -
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 阅读 · 0 评论 -
401 - Palindromes
#include#includechar 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 阅读 · 0 评论 -
465 - Overflow
#include #include #includeint 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 阅读 · 0 评论 -
340 - Master-Mind Hints
#include#includeint main(){int num=0,N,isOver,A,B;intcode[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 阅读 · 0 评论 -
156 - Ananagrams
#include #include #include #include char word[25],words[1500][25],wordsSorted[1500][25],ananagram[1000][25];int cmp(const void*a,const void*b){ return strcmp((char *)a,(char *)b);}int main(原创 2014-09-10 16:08:24 · 366 阅读 · 0 评论 -
120 - Stacks of Flapjacks
#include #include void filp(int Tofilp[],int n,int whereFilp){ n=n-whereFilp+1; int temp; for(int i=0;i<n/2;i++) { temp=Tofilp[i]; Tofilp[i]=Tofilp[n-i-1]; Tofilp[n-i-1]=temp; }}int原创 2014-08-24 23:30:28 · 294 阅读 · 0 评论 -
152 - Tree's a Crowd
#include #include typedef struct{ double x; double y; double z;} Point;Point points[5010];int disCount[10];int main(){ int a,b,c,count=0; while(scanf("%d",&a) && scanf("%d",&b)&& scanf("%原创 2014-08-21 20:01:07 · 350 阅读 · 0 评论 -
299 - Train Swapping
#include int main(){ int N,L,carriages[50],count,temp; scanf("%d",&N); for(int i=0;i<N;i++) { count=0; scanf("%d",&L); for(int j=0;j<L;j++) scanf("%d",&carriages[j]); for(int k=0;k<L;原创 2014-08-21 20:03:33 · 294 阅读 · 0 评论 -
10474 - Where is the Marble?
#include #include int marbles[10000],queries[10000];int main(){ int N,Q,count=0,isFound=0; while(scanf("%d",&N) && scanf("%d",&Q)) { if(N==0 && Q==0) break; count++; for(int i=0;i<N;i++)原创 2014-08-21 19:55:31 · 321 阅读 · 0 评论 -
10010 - Where's Waldorf?
#include#include#includechar grid[55][55],words[55];int locate(char s[],int r,int l,int*m,int*n){inti,j,k,z,east,southeast,south,southwest,west,northwest,north,northeast;for(i=0;i{for(j=0;原创 2014-09-10 16:13:21 · 308 阅读 · 0 评论 -
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 阅读 · 0 评论 -
488 - Triangle Wave
#includeint main(){ int i,j,k,l,n,a,f; scanf("%d",&n); for(i=0;i { scanf("%d%d",&a,&f); for(j=0;j { for(k=1;k { for(l=0;l printf("%d",k); printf("\n"); } fo原创 2014-09-10 16:13:10 · 301 阅读 · 0 评论 -
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 阅读 · 0 评论 -
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 阅读 · 0 评论 -
400 - Unix ls
#include#include#include#includeint 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 阅读 · 0 评论
分享