链接
思路
全场数学题。
忘记爆一爆找规律看看了。
代码
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int _=5e5+7;
const int mod=998244353;
int read() {
int x=0,f=1;char s=getchar();
for(;s>'9'||s<'0';s=getchar()) if (s=='-') f=-1;
for(;s>='0'&&s<='9';s=getchar()) x=x*10+s-'0';
return x*f;
}
void solve() {
int x=read(),y=read();
if(x==y) cout<<x<<"\n";
else if(x>y) cout<<(x+y)<<"\n";
else cout<<(y-(y%x)/2)<<"\n";
}
int main() {
int T=read();
while(T-->0) solve();
return 0;
}