diff --git a/HDOJ/1018_autoAC.cpp b/HDOJ/1018_autoAC.cpp new file mode 100644 index 0000000..9af17df --- /dev/null +++ b/HDOJ/1018_autoAC.cpp @@ -0,0 +1,19 @@ +#include +#include +int main(){ + int i,temp,N; + int number; + long double member=0; + scanf("%d",&N); + while(N--){ + scanf("%d",&number); + member=0; + for(i=1,temp=0;i<=number;i++){ + member+=log10(i*1.0); + } + temp=floor(member)+1; + printf("%d\n",temp); + } + getchar(); + return 0; +} diff --git a/HDOJ/1019_autoAC.cpp b/HDOJ/1019_autoAC.cpp new file mode 100644 index 0000000..fae3fe5 --- /dev/null +++ b/HDOJ/1019_autoAC.cpp @@ -0,0 +1,36 @@ +#include "stdio.h" +__int64 s[1000]; +__int64 hcf(__int64 a,__int64 b) +{ + __int64 r=0; + while(b!=0) + { + r=a%b; + a=b; + b=r; + } + return(a); +} +__int64 lcd(__int64 u,__int64 v,__int64 h) +{ + return(u*v/h); +} +int main(int argc, char* argv[]) +{ + int n,m,i; + while(scanf("%d",&n)==1) + { + while(n--) + { + scanf("%d",&m); + for(i=0;i<=m-1;i++) + scanf("%I64d",&s[i]); + for(i=0;i<=m-2;i++) + { + s[i+1]=lcd(s[i],s[i+1],hcf(s[i],s[i+1])); + } + printf("%I64d\n",s[m-1]); + } + } + return 0; +} diff --git a/HDOJ/1020_autoAC.cpp b/HDOJ/1020_autoAC.cpp new file mode 100644 index 0000000..d3a0d2d --- /dev/null +++ b/HDOJ/1020_autoAC.cpp @@ -0,0 +1,42 @@ +#include +#include +#include +char s[10010]; +int main() +{ + int n; + scanf("%d",&n); + getchar(); + while(n--) + { + int len,i,j,count=1; + memset(s,0,sizeof(s)); + scanf("%s",s); + len=strlen(s); + i=0; + j=i+1; + while(j<=len) + { + if(s[i]!=s[j]) + { + if(count==1) + { + printf("%c",s[i]); + } + else + { + printf("%d%c",count,s[i]); + } + i=j; + j++; + count=1; + } + else + { + j++; + count++; + } + } + printf("\n"); + } +} diff --git a/HDOJ/1021_autoAC.cpp b/HDOJ/1021_autoAC.cpp new file mode 100644 index 0000000..0afde16 --- /dev/null +++ b/HDOJ/1021_autoAC.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; +int main() +{ + int n; + while(cin>>n) + if(n%8 == 2||n%8 == 6) + cout<<"yes"< +int main() +{ + int n,i,j,k; + char in[10],out[10]; + int flag[20]; + while(scanf("%d %s %s",&n,in,out)!=EOF) + { + char stack[1000]; + int top=-1; + i=j=k=0; + while(j +#include +int res[101][200] = {0}; +int temp[200] = {0}; +void add(int *x, int *y){ + int i, t; + for(i=0; x[i]!=0&&y[i]!=0; i++){ + x[i] += y[i] -'0'; + } + for(i; y[i]!=0; i++){ + x[i] += y[i]; + } + for(t=0; x[t]!=0; t++){ + if(x[t+1]!=0){ + x[t+1] += (x[t]-'0')/10; + } + else{ + if((x[t]-'0')/10!=0){ + x[t+1] += (x[t]-'0')/10+'0'; + } + else{ + x[t+1] = 0; + } + } + x[t] = (x[t]-'0')%10+'0'; + } +} +int* multiple(int *x, int *y){ + int i, j, length; + for(i=0; i<200; i++){ + temp[i] = 0; + } + for(i=0; x[i]!=0; i++){ + for(j=0; y[j]!=0; j++){ + if(temp[i+j]!=0){ + temp[i+j] += (x[i]-'0')*(y[j]-'0'); + } + else{ + temp[i+j] += (x[i]-'0')*(y[j]-'0')+'0'; + } + } + } + length = 0; + while(temp[length]!=0){ + length++; + } + for(i=0; i=0){ + if(res[n][i] != 0){ + printf("%c", res[n][i]); + } + i--; + } + printf("\n"); + } + return 0; +} diff --git a/HDOJ/1024_autoAC.cpp b/HDOJ/1024_autoAC.cpp new file mode 100644 index 0000000..f9bd373 --- /dev/null +++ b/HDOJ/1024_autoAC.cpp @@ -0,0 +1,40 @@ +#include +#include +const int MAX = 1000005; +using namespace std; +int num[MAX], pre_max[MAX]; +inline int max(int a, int b) +{ + return a > b ? a : b; +} +int DP(int n, int m) +{ + for(int i = 1; i <= m; ++i) + { + int tmp = 0; + for(int k = 1; k <= i; ++k) + tmp += num[k]; + pre_max[n] = tmp; + for(int j = i+1; j <= n; ++j) + { + tmp = max(pre_max[j-1], tmp) + num[j]; + pre_max[j-1] = pre_max[n]; + pre_max[n] = max(pre_max[n], tmp); + } + } + return pre_max[n]; +} +int main() +{ + int n, m; + while(~scanf("%d%d", &m, &n)) + { + for(int i = 1; i <= n; ++i) + { + scanf("%d", &num[i]); + pre_max[i] = 0; + } + printf("%d\n", DP(n, m)); + } + return 0; +} diff --git a/HDOJ/1025_autoAC.cpp b/HDOJ/1025_autoAC.cpp new file mode 100644 index 0000000..7e7ddf3 --- /dev/null +++ b/HDOJ/1025_autoAC.cpp @@ -0,0 +1,53 @@ +#include +#include +#include +int a[500001]; +int dp[500001]; +int f[500001]; +int binary_search(int k, int l, int h) +{ + int mid; + while (l <= h) + { + mid = (l + h)/2; + if (f[mid] <= k) + l = mid + 1; + else + h = mid - 1; + } + return h; +} +int main() +{ + int n; + int t = 0; + while (scanf("%d", &n) != EOF) + { + ++t; + memset(f, -1, sizeof(f)); + int i; + int tmp1,tmp2; + for (i = 0; i < n; ++i) + { + scanf("%d %d", &tmp1, &tmp2); + a[tmp1] = tmp2; + } + dp[1] = 1; + f[1] = a[1]; + int len = 1; + for (i = 2; i <= n; ++i) + { + int x = binary_search(a[i], 1, len); + dp[i] = x + 1; + if ( f[i] == -1 || a[i] < f[dp[i]] ) + f[dp[i]] = a[i]; + if (dp[i] > len) + len = dp[i]; + } + if (len == 1) + printf("Case %d:\nMy king, at most %d road can be built.\n\n", t, len); + else + printf("Case %d:\nMy king, at most %d roads can be built.\n\n", t, len); + } + return 0; +} diff --git a/HDOJ/1026_autoAC.cpp b/HDOJ/1026_autoAC.cpp new file mode 100644 index 0000000..5abd5d9 --- /dev/null +++ b/HDOJ/1026_autoAC.cpp @@ -0,0 +1,128 @@ +#include +#include +#include +using namespace std; +const int N(103),MAXN(0x6ffffff); +struct point +{ + int x,y; + point *next; +}; +struct path_node +{ + int pre_x,pre_y,time; +}; +int maze[N][N]; +path_node path[N][N]; +point *ans; +bool inq[N][N]; +queue q; +int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0}; +int n,m; +void init() +{ + char x; + getchar(); + memset(maze,0,sizeof(maze)); + memset(path,0,sizeof(path)); + memset(inq,0,sizeof(inq)); + for(int i=0;in-1||y<0||y>m-1||maze[x][y]==-1) + return false; + return true; +} +void search() +{ + point s; + s.x=s.y=0; + q.push(s); + inq[s.x][s.y]=true; + while(!q.empty()) + { + point u=q.front(); + q.pop(); + inq[u.x][u.y]=false; + int nx,ny; + for(int i=0;i<4;i++) + { + nx=u.x+dx[i]; + ny=u.y+dy[i]; + if(path[nx][ny].time>path[u.x][u.y].time+maze[nx][ny]+1&&passable(nx,ny)) + { + path[nx][ny].time=path[u.x][u.y].time+maze[nx][ny]+1; + path[nx][ny].pre_x=u.x; + path[nx][ny].pre_y=u.y; + if(!inq[nx][ny]) + { + point np; + np.x=nx,np.y=ny; + q.push(np); + inq[nx][ny]=true; + } + } + } + } +} +void print() +{ + if(path[n-1][m-1].time!=MAXN) + { + point *node; + int x=n,y=m,t=0; + while(x!=-1) + { + node=new(point); + if(ans) + node->x=x,node->y=y; + else node->x=n-1,node->y=m-1; + node->next=ans; + ans=node; + x=path[node->x][node->y].pre_x; + y=path[node->x][node->y].pre_y; + } + printf("It takes %d seconds to reach the target position, let me show you the way.\n", + path[n-1][m-1].time); + point *p,*next; + for(p=ans;p;p=next) + { + while(maze[p->x][p->y]) + { + printf("%ds:FIGHT AT (%d,%d)\n",++t,p->x,p->y); + maze[p->x][p->y]--; + } + if(p->next) + printf("%ds:(%d,%d)->(%d,%d)\n",++t,p->x,p->y,p->next->x,p->next->y); + next=p->next; + delete p; + } + ans=NULL; + } + else + printf("God please help our poor hero.\n"); + printf("FINISH\n"); +} +int main() +{ + while(scanf("%d%d",&n,&m)!=EOF) + { + init(); + search(); + print(); + } +} diff --git a/HDOJ/1027_autoAC.cpp b/HDOJ/1027_autoAC.cpp new file mode 100644 index 0000000..7bb4bdc --- /dev/null +++ b/HDOJ/1027_autoAC.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +using namespace std; +int a[10000],coun,n,m,i; +int main() +{ + while(cin>>n>>m) + { + for(i=0;i iv(a,a+n); + coun = 1; + while(next_permutation(iv.begin(),iv.end())) + { + coun++; + if(coun==m) + break; + } + printf("%d",iv[0]); + for(i=1;i +#include +using namespace std; +int main() +{ + int n; + int c1[125], c2[125]; + while(~scanf("%d", &n)) + { + for(int i = 0; i <= n; ++i) + { + c1[i] = 1; + c2[i] = 0; + } + for(int i = 2; i <= n; ++i) + { + for(int j = 0; j <= n; ++j) + { + for(int k = 0; k <= n/i*i; k += i) + c2[j+k] += c1[j]; + } + for(int j = 0; j <= n; ++j) + { + c1[j] = c2[j]; + c2[j] = 0; + } + } + printf("%d\n", c1[n]); + } + return 0; +} diff --git a/HDOJ/1029_autoAC.cpp b/HDOJ/1029_autoAC.cpp new file mode 100644 index 0000000..0a74806 --- /dev/null +++ b/HDOJ/1029_autoAC.cpp @@ -0,0 +1,27 @@ +#include + int main() +{ + long n,num,cnt,res; + while(EOF != scanf("%d",&n)) + { + cnt = 0; + while(n--) + { + scanf("%d",&num); + if(0 == cnt) + { + res = num; + cnt++; + } + else + { + if(res == num) + cnt++; + else + cnt--; + } + } + printf("%d\n",res); + } + return 0; +} diff --git a/HDOJ/1030_autoAC.cpp b/HDOJ/1030_autoAC.cpp new file mode 100644 index 0000000..f0e801d --- /dev/null +++ b/HDOJ/1030_autoAC.cpp @@ -0,0 +1,40 @@ +#include +#include +using namespace std; +struct Note +{ + int x; + int y; + int z; +}; +int main() +{ + Note a,b; + int m,n; +while(cin>>m>>n) +{ + int sa=0; + int sb=0; + int k; + int t=ceil(sqrt(m)); + a.x=t; + k=(m-(t-1)*(t-1))/2; + a.y=t-k; + k=((2*t-1)-m+(t-1)*(t-1))/2; + a.z=t-k; + if((2*t-1-m+(t-1)*(t-1))%2==0) sa=1; + if(sa==0) a.z=a.z-1; + t=ceil(sqrt(n)); + b.x=t; + k=(n-(t-1)*(t-1))/2; + b.y=t-k; + k=((2*t-1)-n+(t-1)*(t-1))/2; + b.z=t-k; + if((2*t-1-n+(t-1)*(t-1))%2==0) sb=1;; + if(sb==0) b.z=b.z-1; + int ans=0; + ans=abs(a.x-b.x)+abs(a.y-b.y)+abs(a.z-b.z); + cout< +#include +#include +using namespace std; +struct Node{ +int num; +double times; +}; +Node T[1000]; +int cmp1( const void *a , const void *b ) +{ +struct Node *c = (Node *)a; +struct Node *d = (Node *)b; +if(c->times != d->times) return d->times - c->times; +} +int cmp2( const void *a , const void *b ) +{ +struct Node *c = (Node *)a; +struct Node *d = (Node *)b; +return c->num > d->num ? -1 : 1 ; +} +int main() +{ + int i,j,k,n,m; + double temp; + while(EOF != scanf("%d %d %d",&n,&m,&k)) + { + for(i=0;i +using namespace std; +#define MAXNUM 1000000 + 1 + int result[MAXNUM]; + int main() + { + int beg,end,max,count,temp; + while(cin>>beg>>end) + { + cout< end) + { + temp = beg;beg = end;end = temp; + } + max = count = 0; + for(int t = beg;t <= end;++t) + { + if(result[t]) + count = result[t]; + else + { + temp = t; + count = 1; + while(temp != 1) + { + if(temp%2 == 0) + temp = temp/2; + else + temp = 3*temp + 1; + ++count; + } + result[t] = count; + } + if(count > max) + max = count; + } + cout< +#include +using namespace std; +int main() +{ + string input; + while (cin>>input) + { + cout<<"300 420 moveto"< +using namespace std; +int T[500],T1[500],n; +int check() +{ + int temp = T[0]; + for(int j=1;j +int maze[11][11]; +int r,c,b; +int idx; +void step(int x,int y) +{ + int t; + if(x<0||x>=r||y<0||y>=c) + { + printf("%d step(s) to exit\n",idx-999); + return; + } + if(maze[x][y]>=1000) + { + printf("%d step(s) before a loop of %d step(s)\n",maze[x][y]-1000,idx-maze[x][y]+1); + return; + } + t=maze[x][y]; + idx++; + maze[x][y]=idx; + switch (t) + { + case 'N': + step(x-1,y); + break; + case 'S': + step(x+1,y); + break; + case 'E': + step(x,y+1); + break; + case 'W': + step(x,y-1); + break; + } +} +int main() +{ + int i,j; + while (scanf("%d%d",&r,&c),r||c) + { + scanf("%d",&b); + getchar(); + for (i=0;i +#include +using namespace std; +int main() +{ + int n; + double d; + char* time = new char[8]; + scanf("%d%lf", &n, &d); + int num; + while(scanf("%d", &num) != EOF) + { + int sec = 0; + int flag = 0; + for(int i = 0; i < n; i++) + { + scanf("%s", time); + if(time[0] == '-') + { + flag = 1; + } + else + { + sec += (time[0] - '0') * 3600 + ((time[2] - '0') * 10 + time[3] - '0') * 60 + (time[5] - '0') * 10 + time[6] - '0'; + } + } + if(flag == 0) + { + sec = int(sec * 1.0 / d + 0.5); + int minute = sec / 60; + int second = sec % 60; + printf("%3d: %d:", num, minute); + if(second < 10) + printf("0"); + printf("%d min/km\n", second); + } + else + { + printf("%3d: -\n", num); + } + } + return 0; +} diff --git a/HDOJ/1037_autoAC.cpp b/HDOJ/1037_autoAC.cpp new file mode 100644 index 0000000..c01b506 --- /dev/null +++ b/HDOJ/1037_autoAC.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; +int main() +{ + int a, b, c, min; + while (cin >> a >> b >> c) { + min = a; + if (b < min) min = b; + if (c < min) min = c; + if (min > 168) cout << "NO CRASH" << endl; + else cout << "CRASH " << min << endl; + } + return 0; +} diff --git a/HDOJ/1038_autoAC.cpp b/HDOJ/1038_autoAC.cpp new file mode 100644 index 0000000..0954df4 --- /dev/null +++ b/HDOJ/1038_autoAC.cpp @@ -0,0 +1,20 @@ +#include +#include +using namespace std; +int main(){ + const float pi = 3.1415927; + float diameter_inch; + int circle; + float time_sec; + int count = 1; + while(cin>>diameter_inch>>circle>>time_sec && circle != 0){ + float distance; + float time_hour; + float speed; + distance = pi * diameter_inch * circle / 5280 / 12; + time_hour = time_sec / 3600; + speed = distance / time_hour; + cout<<"Trip #"< +#include +int isvowel(char c){ + if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') + return 1; + else + return 0; +} +int isA(char str[]){ + int i=0,vowel=0,consonant=0,k; + for(k=0;k2) + return 0; + } + else{ + consonant++; + vowel=0; + if(consonant>2) + return 0; + } + if(str[k]!='e'&&str[k]!='o'&&str[k]==str[k+1]) + return 0; + } + if(!i) + return 0; + else + return 1; +} +int main(){ + char str[25]; + while(~scanf("%s",str)){ + if(!strcmp(str,"end")) + break; + if(isA(str)){ + printf("<%s> is acceptable.\n",str); + } + else + printf("<%s> is not acceptable.\n",str); + } +} diff --git a/HDOJ/1040_autoAC.cpp b/HDOJ/1040_autoAC.cpp new file mode 100644 index 0000000..38b44cc --- /dev/null +++ b/HDOJ/1040_autoAC.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; +int main () +{ + int t, n, i; + int *d; + cin >> t; + while (t--) { + cin >> n; + d = (int *)malloc(sizeof(int)*n); + for (i = 0; i < n; i++) { + cin >> d[i]; + } + sort (d, d+n); + cout << d[0]; + for (i = 1; i < n; i++) { + cout << " " << d[i]; + } + cout << endl; + } + return 0; +} diff --git a/HDOJ/1041_autoAC.cpp b/HDOJ/1041_autoAC.cpp new file mode 100644 index 0000000..0d9cbb7 --- /dev/null +++ b/HDOJ/1041_autoAC.cpp @@ -0,0 +1,29 @@ +#include +#include +using namespace std; +string add(string s1,string s2){ + if(s1.length()=0;i--,j--){ + s1[i]=char(s1[i]+( j>=0 ? s2[j]-'0' : 0)); + if(s1[i]-'0'>=10) { + s1[i]=char( (s1[i]-'0')%10+'0' ); + if(i) s1[i-1]++; + else s1="1"+s1; + } + } + return s1; +} +string f[1005]; +int main(){ + int n; + f[1]="0"; f[2]="1"; f[3]="1"; f[4]="3"; f[5]="5"; f[6]="11"; + for(int i=7;i<=1004;i++) + f[i]=add( f[i-1], add(f[i-2],f[i-2]) ); + while(scanf("%d",&n)==1) + cout< +int main() +{ + int a[10000]; + int i,j,c,m,n; + while(scanf("%d",&n)!=EOF){ + a[0]=1; + m=0; + for(i=1;i<=n;i++) + { + c=0; + for(j=0;j<=m;j++) + { + a[j]=a[j]*i+c; + c=a[j]/10000; + a[j]=a[j]%10000; + } + if(c>0) {m++;a[m]=c;} + } + printf("%d",a[m]); + for(i=m-1;i>=0;i--) printf("%4.4d",a[i]); + printf("\n"); + } + return 0; +} diff --git a/HDOJ/1043_autoAC.cpp b/HDOJ/1043_autoAC.cpp new file mode 100644 index 0000000..eaed359 --- /dev/null +++ b/HDOJ/1043_autoAC.cpp @@ -0,0 +1 @@ + 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 x diff --git a/HDOJ/1044_autoAC.cpp b/HDOJ/1044_autoAC.cpp new file mode 100644 index 0000000..8e835b7 --- /dev/null +++ b/HDOJ/1044_autoAC.cpp @@ -0,0 +1,149 @@ +#include +#include +using namespace std; +char map[50][50]; +int distan[12][12]; +int jewels[12][3]; +int mark[50][50]; +int visit[12]; +int sx,sy,ex,ey,dijige,youjige,cancollect,maxjewels,jieshu; +int u,n,m,t,zhubao,flag; +struct node +{ + int x,y,step; +}w,p; +int dir[4][2]={1,0,-1,0,0,1,0,-1}; +int bfs(int qx,int qy,int mx,int my) +{ + queue q; + w.x=qx;w.y=qy;w.step=0; + while(!q.empty()) + q.pop(); + q.push(w); + while(!q.empty()) + { + p=q.front(); + q.pop(); + if(p.x==mx&&p.y==my) + return p.step; + for(int i=0;i<4;i++) + { + w.x=p.x+dir[i][0]; + w.y=p.y+dir[i][1]; + w.step=p.step+1; + if(w.x>=0&&w.x=0&&w.y=0&&weizhi==zhubao+1) + { + maxjewels=jewel; + flag=1; + jieshu=1; + return; + } + if(weizhi==zhubao+1&&step>=0) + { + flag=1; + if(jewel>maxjewels) + maxjewels=jewel; + return; + } + for(int i=0;i>u; + youjige=u; + dijige=1; + while(u--) + { + memset(jewels,0,sizeof(jewels)); + cin>>m>>n>>t>>zhubao; + for(int i=0;i>jewels[i][2]; + memset(distan,1000001,sizeof(distan)); + memset(mark,0,sizeof(mark)); + memset(visit,0,sizeof(visit)); + for(int i=0;i>map[i][j]; + if(map[i][j]=='@') + { + sx=i; + sy=j; + } + if(map[i][j]=='<') + { + ex=i; + ey=j; + } + if(map[i][j]>='A'&&map[i][j]<='J') + { + jewels[map[i][j]-'A'][0]=i; + jewels[map[i][j]-'A'][1]=j; + } + } + } + cancollect=0; + for(int i=0;i +char maze[6][6]; +int num,result; +bool placeable(int row,int col) +{ + int i; + i=col-1; + while(i>=0&&maze[row][i]!='X') + if(maze[row][i--]=='*') return false; + i=row-1; + while(i>=0&&maze[i][col]!='X') + if(maze[i--][col]=='*') return false; + return true; +} +void dfs(int cnt,int max) +{ + int row,col; + if(cnt==num*num) + { + max>result?result=max:1; + return; + } + else + { + row=cnt/num; + col=cnt%num; + if(maze[row][col]=='.'&&placeable(row,col)) + { + maze[row][col]='*'; + dfs(cnt+1,max+1); + maze[row][col]='.'; + } + dfs(cnt+1,max); + } +} +int main() +{ + while(scanf("%d",&num)!=EOF&&num) + { + for(int i=0;i +#include +#include +#include +using namespace std; +int main(void) +{ + int n; + scanf("%d", &n); + for (int i = 1; i < n + 1; ++i) + { + printf("Scenario #%d:\n", i); + int s, t; + scanf("%d%d",&s,&t); + double sum; + sum = s*t; + if ((s*t)%2) + printf("%.2f\n", sum+sqrt(2)-1); + else printf("%.2f\n", (double)sum); + printf("\n"); + } + return 0; +} diff --git a/HDOJ/1047_autoAC.cpp b/HDOJ/1047_autoAC.cpp new file mode 100644 index 0000000..68cc3f9 --- /dev/null +++ b/HDOJ/1047_autoAC.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +#define maxn 300 +using namespace std; +int numx[maxn],numy[maxn],n; +string str,tmp; +string Add(string x,string y){ + string res=""; + memset(numx,0,sizeof(numx)); + memset(numy,0,sizeof(numy)); + int lenx=x.size(),leny=y.size(); + int maxlen=lenx>leny ? lenx:leny; + for(int i=0;i9){ + numx[i+1]+=numx[i]/10; + numx[i]%=10; + } + } + int i=maxlen+2; + for(;i>0&&!numx[i];)i--; + for(;i>=0;i--)res+=numx[i]+'0'; + return res; +} +int main() +{ + while(cin>>n){ + while(n--){ + string sum="0"; + while(cin>>str&&str!="0"){ + sum=Add(sum,str); + } + cout< +#include +using namespace std; +const int LEN = 210; +char engChars[30] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}; +char aLine[LEN]; +void decipher() +{ + for (int i = 0;i < strlen(aLine);i ++) + { + if (isalpha(aLine[i])) + { + int offset = (aLine[i] - 'A' + 26 - 5) % 26; + aLine[i] = engChars[offset]; + } + } +} +int main () +{ + while (gets(aLine)) + { + if (strcmp(aLine,"ENDOFINPUT") == 0) + break; + while (1) + { + gets(aLine); + if (strcmp(aLine,"END") == 0) + break; + decipher(); + printf("%s\n",aLine); + } + } + return 0; +} diff --git a/HDOJ/1049_autoAC.cpp b/HDOJ/1049_autoAC.cpp new file mode 100644 index 0000000..e335911 --- /dev/null +++ b/HDOJ/1049_autoAC.cpp @@ -0,0 +1,7 @@ +#include +int main(){ + int n,u,d,t; + while(scanf("%d%d%d",&n,&u,&d)!=-1&&n) + printf("%d\n",(n-u)%(u-d)?(2*((n-u)/(u-d)+1)+1):(2*((n-u)/(u-d))+1)); + return 0; +} diff --git a/HDOJ/1050_autoAC.cpp b/HDOJ/1050_autoAC.cpp new file mode 100644 index 0000000..ad39f88 --- /dev/null +++ b/HDOJ/1050_autoAC.cpp @@ -0,0 +1,30 @@ +#include +#include +using namespace std; +int f[201]; +int main() +{ + int t, n, i, j, s, e; + cin >> t; + while( t-- ){ + memset( f, 0, sizeof(f) ); + cin >> n; + for( i=0; i> s >> e; + s = (s+1)/2; + e = (e+1)/2; + if( s > e ){ + int temp = s; + s = e; + e = temp; + } + for( j=s; j<=e; j++) + f[j]++; + } + int consume = 0; + for( i=1; i<=200; i++ ) + consume = max( consume, f[i] ); + cout << consume*10 << endl; + } + return 0; +}