P4101求调

题目总版

__KevinMZ__ @ 2024-09-17 12:59:45

P4101

#include<bits/stdc++.h>
#define int long long
signed main(){
    ios::sync_with_stdio(0);
    int t, n, m;
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        if(n <= m)
        {
            cout << (n & 1)<< "\n";
            continue;
        }
        if(m & 1) //m是奇数 
        {
            if(n % m % 4 < 2) puts("1");
            else puts("0");
        }
        else //m是偶数 
        {
            if(n % m % 4 < 2) puts("0");
            else puts("1");
        }
    }
    return 0;
}

by TC_Austin @ 2024-09-17 13:09:01

@KevinMZ 你看这道题的难度,再看看你的代码


by __KevinMZ__ @ 2024-09-17 13:11:54

所以你看看题解的代码长度 @TC_Austin


by switchwanjia @ 2024-09-17 21:39:47

@KevinMZ

#include<cstdio>
#include<iostream>
using namespace std;
int T;
long long int n,m;
int main()
{
    scanf("%d",&T);
    for(int i=1;i<=T;i++)
    {
        scanf("%lld%lld",&n,&m);
        long long int ans=(n/m)*(m-1)+((n%m)?(n%m-1):0);
        if(ans&1) printf("0\n");
        else printf("1\n");
    }
    return 0;
}

by switchwanjia @ 2024-09-17 21:40:31

@KevinMZ 记得给关注


by switchwanjia @ 2024-09-17 21:41:58

@KevinMZ 要不要加入团队


|