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;
}
///这场是被带的。。。