2020牛客暑期多校训练营(第一场)F

Description

定义字符串的幂为字符串不断循环重复的结果。给定两个字符串,比较它们无穷次幂的大小。

Solution

暴力比较,设个上限

#include <bits/stdc++.h>
using namespace std;

const int N = 100005;
char a[N],b[N];

signed main()
{
    ios::sync_with_stdio(false);

    while(~scanf("%s%s",a,b))
    {
        int flag=0;
        int n=strlen(a), m=strlen(b);
        for(int i=0;i<4*max(n,m);i++)
        {
            if(a[i%n]>b[i%m])
            {
                flag=1;
                break;
            }
            if(a[i%n]<b[i%m])
            {
                flag=-1;
                break;
            }
        }
        if(flag==1) puts(">");
        if(flag==-1) puts("<");
        if(flag==0) puts("=");
    }
}