Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
strncmp(), 用这个函数几行搞定,94ms#include <cstdio> #include <algorithm> #include <cstring> using namespace std; char str[20005]; int N; void solve() { int ans=0; for(int i=1;i<N;i++) { if(strncmp(str+ans,str+i,N)>0) ans=i; } printf("%d\n",ans+1); } int main() { #ifndef ONLINE_JUDGE freopen("data.in","r",stdin); #endif int T; scanf("%d",&T); while(T--) { scanf("%s",str); N=strlen(str); for(int i=0;i<N;i++) str[N+i]=str[i]; solve(); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator