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

2020 牛客暑期多校训练营(第一场)F_第1张图片
题目大意:
多次输入两个a,b字符串他们可以无限次的重复变成aaa,或者bbb
比较他们的大小,相同输出 =,ab输出 >.
输入:

aa
b
zzz
zz
aba
abaa

输出:

<
=
>

Code:

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const int maxn = 1<<17;
const int p = 998244353;
int main()
{
    string a,b;
    while(cin >> a >> b)
    {
        int l1=a.size(),l2=b.size();
        for(int i=0;; i++)
        {
            if(a[i%l1]b[i%l2])
            {
                printf(">\n");
                break;
            }
            if(i==l1+l2-1)
            {
                printf("=\n");
                break;
            }
        }

    }
    return 0;
}

Code:

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const int maxn = 1<<17;
const int p = 998244353;
int main()
{
    string a,b;
    while(cin >> a >> b)
    {
        if(a+b < b+a)
            cout << '<' << endl;
        else if(a+b == b+a)
            cout << '=' << endl;
        else
            cout << '>' << endl;
    }
}

你可能感兴趣的:(2020牛客多校训练)