其他分享
首页 > 其他分享> > Moderate Modular Mode %,取模运算性质,数轴,思维

Moderate Modular Mode %,取模运算性质,数轴,思维

作者:互联网

在这里插入图片描述
题意:

思路:

#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int _;
    cin >> _;
    
    while (_ -- )
    {
        ll x, y;
        cin >> x >> y;
        if (x == y) cout << x << endl;
        else if (x > y) cout << x + y << endl;
        else cout << y - y % x / 2 << endl;
    }
    
    return 0;
}

标签:取模,cout,数轴,int,ll,y%,cin,long,Modular
来源: https://blog.csdn.net/m0_51448653/article/details/121114366