#include<stdio.h> #include<string.h> int main() { // freopen("input.txt","r",stdin); char ch[1000]; while(gets(ch)!=NULL) { if(strcmp(ch,"e/o/i")==0)break; int i=0,j,k,l,m=0,n=1,f=0,l1=0,l2=0,l3=0; while(ch[i]!='/') { if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y') { m=1; } else { if(m==1) l1++; m=0; } i++; } if(m==1) { l1++; m=0; } i++; while(ch[i]!='/') { if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y') { m=1; } else { if(m==1) l2++; m=0; } i++; } if(m==1) { l2++; m=0; } i++; ch[strlen(ch)]='/'; while(ch[i]!='/') { if(ch[i]=='a'||ch[i]=='e'||ch[i]=='i'||ch[i]=='o'||ch[i]=='u'||ch[i]=='y') { m=1; } else { if(m==1) l3++; m=0; } i++; } if(m==1) { l3++; m=0; } i++; if(l1!=5)printf("1\n"); else if(l2!=7)printf("2\n"); else if(l3!=5)printf("3\n"); else printf("Y\n"); } return 0; }
Utopia
struggle forever
Saturday, August 30, 2014
uva : 576 - Haiku Review
uva : 573 - The Snail
#include <iostream> using namespace std; int main() { double h,u,d,f; while (cin>>h>>u>>d>>f) { if (h==0) break; int day=0; double fatigue=u*f/100.0,height=0; while (height<h && height>=0) { double climbed=u-fatigue*day; if (fatigue<=climbed) height+=climbed; day++; if (height>h) break; height-=d; // cout<<"height = "<<height<<endl; } if (height>=h) cout<<"success on day "<<day<<endl; else if (height<0) cout<<"failure on day "<<day<<endl; } return 0; }
uva : 572 - Oil Deposits
#include<cstdio> #include<queue> using namespace std; int main() { //freopen("input.txt","r",stdin); int row,col; while(scanf("%d %d\n",&row,&col)==2&&(row+col)!=0) { int number[row+1][col+1]; for(int i=1;i<=row;i++) { for(int j=1;j<=col;j++) { char ch=getchar(); if(ch=='*')number[i][j]=0; else if(ch=='@')number[i][j]=1; } getchar(); } int count=0; for(int i=1;i<=row;i++) { for(int j=1;j<=col;j++) { if(number[i][j]==1) { count++; queue<int>r,c; r.push(i); c.push(j); while(!r.empty()) { int x=r.front(),y=c.front(); r.pop();c.pop(); if(x-1>0&&number[x-1][y]==1) { r.push(x-1);c.push(y);number[x-1][y]=0; } if(y-1>0&&number[x][y-1]==1) { r.push(x);c.push(y-1);number[x][y-1]=0; } if(x+1<=row&&number[x+1][y]==1) { r.push(x+1);c.push(y);number[x+1][y]=0; } if(y+1<=col&&number[x][y+1]==1) { r.push(x);c.push(y+1);number[x][y+1]=0; } if(x-1>0&&y-1>0&&number[x-1][y-1]==1) { r.push(x-1);c.push(y-1);number[x-1][y-1]=0; } if(x-1>0&&y+1<=col&&number[x-1][y+1]==1) { r.push(x-1);c.push(y+1);number[x-1][y+1]=0; } if(x+1<=row&&y-1>0&&number[x+1][y-1]==1) { r.push(x+1);c.push(y-1);number[x+1][y-1]=0; } if(x+1<=row&&y+1<=col&&number[x+1][y+1]==1) { r.push(x+1);c.push(y+1);number[x+1][y+1]=0; } } } } } printf("%d\n",count); } return 0; }
Subscribe to:
Posts (Atom)