B - Shell Game 打表找规律

本文介绍了一种通过观察和分析规律来解决特定数学问题的竞赛编程技巧。针对不同条件下的输入,文章提供了具体的解决方案,展示了如何根据输入数字的特性快速得出结果。

传送门
思路:打表/手写找规律。
///今天训练赛做的太紧张了,真辣鸡!!!

/**
* From:
* Qingdao Agricultural University
* Created by XiangwangAcmer
* Date : 2019-10-29-18.58.22
* Talk is cheap.Show me your code.
*/
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<cctype>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<cstdlib>
#define ll long long
#define ull unsigned long long
#define ios ios::sync_with_stdio(false);
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
using namespace std;
const ll maxn = 1e6 + 5;
const ll minn = 1e9 + 5;
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LIMIT = 4294967295LL;
ll gcd(ll a, ll b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
vector<int>v[maxn];
int dp[maxn];
vector<int>G[maxn];
bool row[maxn], col[maxn];
bool flag = 0;
queue<int>q;
set<char>s;
set<set<char> >ss;
ll vis1[maxn], vis2[maxn], vis3[maxn];
int main()
{
    ios
    int n, m;
    cin >> n >> m;
    if(m == 2)
    {
        if(n % 6 == 4 || n % 6 == 5)
            cout << 1 << endl;
        else if(n % 6 == 1 || n % 6 == 0)
            cout << 2 << endl;
        else cout << 0 << endl;
    }
    else if(m == 1)
    {
        if(n % 3 == 0)
            cout << 1 << endl;
        else if(n % 3 == 2)
            cout << 2 << endl;
        else cout << 0 << endl;
    }
    else if(m == 0)
    {
        if(n % 6 == 1||n%6 ==2)
            cout << 1 <<endl;
        else if(n % 6 == 3 || n%6 == 4)
            cout << 2 << endl;
        else cout << 0 <<endl;
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值