Submission #727933

# Submission time Handle Problem Language Result Execution time Memory
727933 2023-04-21T15:41:20 Z rainboy CATS (NOI14_cats) C
25 / 25
73 ms 2200 KB
#include <stdio.h>

int count(long long b) {
	return b == 0 ? 0 : count(b & b - 1) + 1;
}

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		long long k, l, n, d;

		scanf("%lld%lld%lld", &k, &l, &n), k--, d = (l + n * 2) / (n * 2);
		printf("%lld\n", d * n * 2 + count(d >= 60 ? k : k % (1LL << d + 1)) % 2);
	}
	return 0;
}

Compilation message

cats.c: In function 'count':
cats.c:4:34: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    4 |  return b == 0 ? 0 : count(b & b - 1) + 1;
      |                                ~~^~~
cats.c: In function 'main':
cats.c:15:66: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   15 |   printf("%lld\n", d * n * 2 + count(d >= 60 ? k : k % (1LL << d + 1)) % 2);
      |                                                                ~~^~~
cats.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
cats.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%lld%lld%lld", &k, &l, &n), k--, d = (l + n * 2) / (n * 2);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 2164 KB Output is correct
2 Correct 73 ms 2200 KB Output is correct