ICL2019E

https://www.codechef.com/ICL2019/problems/ICL1906

 两个整数,[0,1e5]
操作1是让两个数同时减1(只有都大于0的时候才可以用)
操作2可以让一个数乘2
问让两个数都变成0的最小操作次数 
 
直接贪心。能乘就乘。
 #include <bits/stdc++.h>
using namespace std;
int t,x,y;
int main(){
ios::sync_with_stdio(false);
cin>>t;
while (t--){
cin>>x>>y;
if(x==&&y==){
cout<<<<endl;
continue;
}
if(x==||y==){
cout<<-<<endl;
continue;
}
if(x>y)swap(x,y);
int ans = ;
while (x!=y){
if(x*<=y){
x*=;
ans++;
}else{
y--,x--;
ans++;
}
}
ans+=x;
cout<<ans<<endl;
}
}
上一篇:我对老师的一点回忆(20211318)


下一篇:Linux系统-解压缩命令集合