2020牛客多校第一场FJ

F

判断两个无限循环串大小

/*
* @Author: Admin
* @Date:   2020-07-12 12:07:02
* @Last Modified by:   Admin
* @Last Modified time: 2020-07-12 12:12:41
*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> pll;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
ll qpow(ll base, ll n){ll ans = 1; while (n){if (n & 1) ans = ans * base % mod; base = base * base % mod; n >>= 1;} return ans;}
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
char a[N], b[N];
int judge(int n, int m){
 int x = 0, y = 0;
    int cnt = 0;
    int limit = 3 * max(n, m);
 while (cnt < limit){
        ++ cnt;
  x %= n;
  y %= m;
  if (a[x] < b[y]) return -1;
  else if (a[x] > b[y]) return 1;
  ++ x;
  ++ y;
 }
 return 0;
}
int main()
{
 while (scanf("%s %s", a , b) != EOF){
  int n = strlen(a);
  int m = strlen(b);
  int f = judge(n, m);
  if (f == -1) printf("<\n");
  else if (f == 0) printf("=\n");
  else printf(">\n");
 }
 return 0;
}

J 推公式

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> pll;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
ll qpow(ll base, ll n){ll ans = 1; while (n){if (n & 1) ans = ans * base % mod; base = base * base % mod; n >>= 1;} return ans;}
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
char a[N], b[N];
int judge(int n, int m){
    int x = 0, y = 0;
    int cnt = 0;
    int limit = 3 * max(n, m);
    while (cnt < limit){
        ++ cnt;
        x %= n;
        y %= m;
        if (a[x] < b[y]) return -1;
        else if (a[x] > b[y]) return 1;
        ++ x;
        ++ y;
    }
    return 0;
}
int main()
{
    while (scanf("%s %s", a , b) != EOF){
        int n = strlen(a);
        int m = strlen(b);
        int f = judge(n, m);
        if (f == -1) printf("<\n");
        else if (f == 0) printf("=\n");
        else printf(">\n");
    }
    return 0;
}

///这场是被带的。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值