Submission #322039

# Submission time Handle Problem Language Result Execution time Memory
322039 2020-11-13T23:58:04 Z super_j6 CATS (NOI14_cats) C++14
25 / 25
72 ms 8044 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

ll n, m, k;

void answer(){
	cin >> n >> m >> k;
	n--, k *= 2, m = m / k + 1;
	
	ll ret = k * m++;
	ret |= __builtin_popcountll(m <= __lg(n) ? n & ((1ll << m) - 1) : n) & 1;

	cout << ret << endl;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int t;
	cin >> t;
	
	for(int i = 0; i < t; i++) answer();

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 492 KB Output is correct
2 Correct 5 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 2284 KB Output is correct
2 Correct 72 ms 8044 KB Output is correct