# include <stdio.h>
# include <algorithm>
# include <iostream>
# include <string.h>
# include <string>
using namespace std;
struct node
{
int pos;///初始位置
int num;///跳的次数
int dd;///跳的间隔
int last;///最后位置
};
struct node s[110];
int cmp(node a1,node a2)
{
if(a1.num!=a2.num)
return a1.num>a2.num;
else if(a1.last!=a2.last)
return a1.last>a2.last;
else if(a1.pos!=a2.pos)
return a1.pos>a2.pos;
else if(a1.dd!=a2.dd)
return a1.dd<a2.dd;
}
int main()
{
char a[110];
int len,i,d;
while(~scanf("%s",a))
{
if(strcmp(a,"END")==0)
break;
else
{
len=strlen(a);
int k1=0;
for(i=0; i<len; i++) ///初始位置
{
for(d=1; d<=len; d++) ///跳的间隔
{
int cot=0;
int tt=i;
s[k1].pos=i;
s[k1].dd=d;
for(tt=i; tt<len; tt+=d)
{
s[k1].last=tt;///
if(a[tt]!='.')
break;
cot++;
}
s[k1].num=cot;
k1++;
}
}
sort(s,s+k1,cmp);
printf("%d %d\n",s[0].pos,s[0].dd);
}
}
return 0;
}
ZOJ 2938 Rock Skipping (暴力枚举)
最新推荐文章于 2016-04-19 22:36:36 发布