C. K-th Not Divisible by n
C.K-不可被n整除
time limit per test: 1 second
每次测试的时间限制:1秒
memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节
input. standard input
投入。标准输入
output: standard output
产出:标准产出
You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.
给你两个正整数n和k,打印不可被n整除的第k个正整数。
For example, ifn= 3, andk = 7, then all numbers that are not divisible by 3are: 1,2,4, 5,7, 8, 10, 11, 13… The 7-th number among
例如,IFN=3,k=7,那么所有不能被3整除的数字是:1,2,4,5,7,8,10,11,13.第7位
themis 10.
是10号。
Input
输入
The first line contains an integert(1≤t≤1000)- the number of test cases in the input. Next, t test cases are given, one per line.
第一行包含一个整数(1≤t≤1000)–输入中的测试用例数。接下来,给出t测试用例,每一行一个。
Each test case is two positive integersn(2 < n≤10)andk(1≤k≤109).
每个测试用例是两个正整数(2<n≤10)和k(1≤k≤109)。
Output
输出量
For each test case print the k-th positive integer that is not divisible by n.
对于每个测试用例,打印不可被n整除的k个正整数。
我已经找到了一个绝妙的证明方法,但是这里太窄了,写不下
数论
int main()
{
int t;
cin >> t;
while (t--)
{
int n, k,ans;
cin >> n >> k;
ans = k+((k-1)/(n-1));
cout << ans<<endl;
}
return 0;
}