|
|
back to boardWA10, help me please) #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> int main() { int n, k; scanf("%d %d", &n, &k); if (n < 1 || n > pow(10, 9) || k < 1 || k > pow(10, 9)) { return 0; } unsigned long long result = 0; unsigned long long buffer = 1; n--; for (int i = 0; n >= 0; i++) { n -= buffer; result++; buffer *= 2; if (n <= 0) { printf("%llu\n", result); return 0; } if (buffer >= k) { buffer = k; double count = (double)n / buffer; if (count != (long long)count) { count++; } result += count; printf("%llu\n", result); return 0; } } return 0; } Edited by author 21.01.2020 01:57 Re: WA10, help me please) Posted by Kin 1 Sep 2021 15:18 Test 10 is n = 1 |
|
|