HUST 1372 marshmallow
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HUST 1372 marshmallow相关的知识,希望对你有一定的参考价值。
很简单的博弈题.....算几组能得到规律了。
某个状态先手要赢 等价于 之前有一种状态是后手赢,先手可以保证让现在这个状态到达那个状态
#include<cstdio> #include<cstring> #include<ctime> #include<algorithm> using namespace std; const int maxn = 10000 + 10; int a[maxn], b[maxn]; int n, m; int gcd(int a, int b) { int t; while (b) { t = a%b; a = b; b = t; } return a; } void init() { for (int i = 1; i <= 10000; i++) a[i] = i, b[i] = i; for (int i = 3; i <= 10000; i = i + 3) { swap(b[i - 1], b[i - 2]); } b[10000] = 10001; } int main() { init(); while (~scanf("%d%d", &n, &m)){ int tot = 0; for (int i = 1; i <= 10000; i++) if (a[i] <= n&&b[i] <= m) tot++; int fz, fm; fz = tot; fm = m*n; if (tot == 0) fz = 0, fm = 1; else { int a=fz / gcd(fz, fm),b = fm / gcd(fz, fm); fz = a; fm = b; } printf("%d/%d\n", fz, fm); } return 0; }
以上是关于HUST 1372 marshmallow的主要内容,如果未能解决你的问题,请参考以下文章