Time Limit: 24000/12000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 798 Accepted Submission(s): 387
1 #include <iostream> 2 #include <stdio.h> 3 #include <algorithm> 4 #include <string.h> 5 #include <set> 6 using namespace std; 7 char s[400000],a[400000]; 8 int moremin(char s[],int l) 9 { 10 int i,j,k,t; 11 i=k=0,j=1; 12 while(i<l&&j<l&&k<l) 13 { 14 int t=s[i+k>=l?i+k-l:i+k]-s[j+k>=l?j+k-l:j+k]; 15 if(!t)k++; 16 else 17 { 18 if(t>0)i+=k+1; 19 else j+=k+1; 20 if(i==j)j++; 21 k=0; 22 } 23 } 24 return (i>j?j:i); 25 } 26 int main() 27 { 28 int i; 29 while(~scanf("%s",a)) 30 { 31 int l=strlen(a); 32 for(i=0;i<l;i++) 33 if(a[i+1>=l?i+1-l:i+1]>=a[i]) 34 s[i]=a[i+1>=l?i+1-l:i+1]-a[i]+‘0‘; 35 else s[i]=8+a[i+1>=l?i+1-l:i+1]-a[i]+‘0‘; 36 s[i]=‘\0‘; 37 int x=moremin(s,l); 38 for(i=0;i<l;i++) 39 putchar(s[i+x>=l?i+x-l:i+x]); 40 puts(""); 41 } 42 }
hdu 4162 Shape Number,布布扣,bubuko.com
原文:http://www.cnblogs.com/ERKE/p/3832942.html