2022浙江省赛 A题题解

Problem A:JB Loves Math

本题难度不大,但本蒟蒻一直被卡在Test 2上不动了,改了近一小时终于改出来了,本蒟蒻发题解纪念一下。

#include<bits/stdc++.h>

using namespace std;
using ll=long long;
int t,a,b;
void solve(){
	if(a>b){
        if(!((a-b)&1)) cout<<"1"<<endl;
        else cout<<"2"<<endl;
    }else if(a<b){
        if((b-a)&1) cout<<"1"<<endl;
        else{
            if(((b-a)/2)&1) cout<<"2"<<endl;
            else cout<<"3"<<endl;
        }
    }else if(a==b){
        cout<<"0"<<endl;
    }
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
        cin>>a>>b;
    	solve();
    }
	return 0;
}
posted @ 2024-05-01 18:49  椰萝Yerosius  阅读(15)  评论(0)    收藏  举报  来源