0
点赞
收藏
分享

微信扫一扫

C. K-th Not Divisible by n(数学+思维) Codeforces Round #640 (Div. 4)

原题链接: ​​https://codeforces.com/problemset/problem/1352/C​​

C. K-th Not Divisible by n(数学+思维)  Codeforces Round #640 (Div. 4)_#define

测试样例:

Input
2
3 7
4 12
Output
10
15

解题思路: 这道题是一道水题。对于这道题,我们可以以C. K-th Not Divisible by n(数学+思维)  Codeforces Round #640 (Div. 4)_整除_02的倍数为分界线(这里认为0也是),那么之间相隔了C. K-th Not Divisible by n(数学+思维)  Codeforces Round #640 (Div. 4)_整除_03个不能被a整除,我们找第C. K-th Not Divisible by n(数学+思维)  Codeforces Round #640 (Div. 4)_整除_04大的就是那么就找它在第C. K-th Not Divisible by n(数学+思维)  Codeforces Round #640 (Div. 4)_整除_05个整数和第C. K-th Not Divisible by n(数学+思维)  Codeforces Round #640 (Div. 4)_整除_06整数之间的第几个数。具体看代码。

AC代码:

/*

*
*/
#include<bits/stdc++.h> //POJ不支持

#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int inf = 0x3f3f3f3f;//无穷大
const int maxn = 1e5;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割线,以上为自定义代码模板***************************************//

ll a,b;
int t;
int main(){
//freopen("in.txt", "r", stdin);//提交的时候要注释掉
IOS;
while(cin>>t){
while(t--){
cin>>a>>b;
ll sum;
int t=b/(a-1);
if(t*(a-1)==b){
sum=(t-1)*a+a-1;
}
else{
sum=t*a+b-t*(a-1);
}
cout<<sum<<endl;
}
}
return 0;
}


举报

相关推荐

0 条评论