zoukankan      html  css  js  c++  java
  • 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
    ", fz, fm);
        }
        return 0;
    }
  • 相关阅读:
    键盘快捷键
    电脑命令行命令
    网络基础TCP/IP
    运算符优先级
    元字符汇总
    正则表达式
    模板语法(DOM与Vue数据绑定)
    computed、methods、watch
    vue实例
    坐标轴
  • 原文地址:https://www.cnblogs.com/zufezzt/p/5211767.html
Copyright © 2011-2022 走看看