Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution
Problem Link https://codeforces.com/contest/2009/problem/C
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- long long x , y , k ; cin >> x >> y >> k ;
- long long n_x , n_y ;
- n_x = (x + k - 1)/ k ;
- n_y = (y + k - 1)/ k ;
- if( n_x > n_y){
- cout << ( 2 * n_x ) - 1<<'\n';
- }
- else {
- cout <<2 * n_y <<'\n';
- }
- }
- return 0 ;
- }
No comments