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 @   椰萝Yerosius  阅读(3)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示