| ||||||||||
| 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 | |||||||||
状告POJ这个程序虽然是暴力但思维有漏洞我自杀,过了所有数据!!!!!!#include <iostream>
#include <algorithm>
using namespace std;
char c[10010],len;
int cmp(int a,int b)
{
int i=a,j=b;
do
{
if(c[i]>c[j])return 1;
else if(c[j]>c[i])return 2;
i++;
j++;
i=i%len;
j=j%len;
}
while(i%len!=a&&j%len!=b);
return 0;
}
int main()
{
int n,i,j;
scanf("%d",&n);
while(n--)
{
scanf("%s",c);
len=strlen(c);
int max=0;
for(i=1;i<len;i++)
{
if(cmp(i,max)==2)max=i;
}
printf("%d\n",max+1);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator