2020牛客多校(第一场) F- Infinite String Comparision

 

 

 一开始还用了lcm 疯狂超时 

 暴力跑一边s1+s2的长度就行了

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
using namespace std;
#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long
#define INT_INF 0x7fffffff
#define pi acos(-1)
#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)
#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);
#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);
#define _T_(T) int T;scanf("%d",&T);while (T --)
#define _E_(T) while (~T)
#define endl '\n'
#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return
#define eps 1e-10
const int maxn = 1e6 + 10;
long long gcd(long long a, long long b)
{
    return b == 0 ? a : gcd(b, a%b);
}
long long lcm(long long  a, long long b)
{
    return a * (b/gcd(a, b)); 
}
int main(){ 
    
    string a,b;
    while(cin>>a>>b){
    int flag1=0,flag2=0,flag=0;//1> 2< 0=
    for(long long i=0;i<b.length()+a.length();i++){
       if(a[flag1]>b[flag2]){
           flag=1;
           break;
       }
       if(a[flag1]<b[flag2]){
           flag=2;
           break;
       }
       flag1++;
       flag2++;
       if(flag1>a.length()-1)flag1=0;
       if(flag2>b.length()-1)flag2=0;
    }
    if(flag==0)cout<<"="<<endl;
    else if(flag==1)cout<<">"<<endl;
    else if(flag==2)cout<<"<"<<endl;
    }
    
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值