跳到正文

个人记录

codeforces round 1072_a、b

YuKeWang约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年1月14日
更新
2026年1月14日
篇幅
约 1 分钟

版本

  1. v1当前
C++
// A
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	int T;
	cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		if(n==2)cout<<2<<endl;
		else if(n==3)cout<<3<<endl;
		else
		{
			if(n%2==1)cout<<1<<endl;
			else cout<<0<<endl;
		}
	}
	return 0;
}

//B
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int T;
    cin>>T;
    while(T--)
    {
        int s,m,k;
        cin>>s>>m>>k;
        int times=k%(2*m);
        if(times>=m)
        {
			times-=m;
			s=min(s,m);
		}
		if(times==0)
			cout<<s<<endl;
		else if(times<=s)
			cout<<s-times<<endl;
		else cout<<0<<endl;
    }
    return 0;
}
原文