Codeforces Round #699 (Div. 2)
A. K-divisible Sum
You are given two integers n and k.
You should create an array of n positive integers a1,a2,…,an such that the sum (a1+a2+⋯+an) is divisible by k and maximum element in a is minimum possible.
What is the minimum possible maximum element in a?
Input
The first line contains a single integer t (1≤t≤1000) — the number of test cases.
The first and only line of each test case contains two integers n and k (1≤n≤109; 1≤k≤109).
Output
For each test case, print one integer — the minimum possible maximum element in array a such that the sum (a1+⋯+an) is divisible by k.
代码:
int T;
int main(){
sd1(T);
while(T--){
LL n, k;
sd2(n, k);
LL ans = 0;
if(k >= n){
if(k % n == 0) ans = k / n;
else ans = k / n + 1;
}
else{
if(n % k == 0){
ans = 1;
}
else{
ans = 2;
}
}
cout << ans << endl;
}
system("pause");
return 0;
}
B. Inflation
You have a statistic of price changes for one product represented as an array of n positive integers p0,p1,…,pn−1, where p0 is the initial price of the product and pi is how the price was increased during the i-th month.
Using these price changes you are asked to calculate