Submission #741661

# Submission time Handle Problem Language Result Execution time Memory
741661 2023-05-14T14:11:32 Z jongjip Intercastellar (JOI22_ho_t1) C
0 / 100
12 ms 24248 KB
#include <stdio.h>
#include <stdlib.h>

unsigned long long count_powers_of_two(unsigned long long n) {
  unsigned long long count = 0;
  while (n != 0) {
    n &= (n - 1);
    count++;
  }
  return count;
}

int main() {
  int n, q, j;
  unsigned long long a[1020406], x[1020406], aa[1020406];

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%lld", &x[i]);
  }

  for (int i = 0; i < n; i++) {
    aa[i] = count_powers_of_two(a[i]);
  }

  for (int i = 0; i < q; i++) {
    j = 0;
    while (x[i] > aa[j]) {
      j++;
    }
    printf("%llu\n", a[j]);
  }
}

Compilation message

Main.c: In function 'main':
Main.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   scanf("%d", &n);
      |   ^~~~~~~~~~~~~~~
Main.c:19:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%lld", &a[i]);
      |     ^~~~~~~~~~~~~~~~~~~~
Main.c:21:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &q);
      |   ^~~~~~~~~~~~~~~
Main.c:23:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%lld", &x[i]);
      |     ^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 24248 KB Output is correct
2 Incorrect 11 ms 24244 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 24148 KB Output is correct
2 Incorrect 10 ms 24228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 24248 KB Output is correct
2 Incorrect 11 ms 24244 KB Output isn't correct
3 Halted 0 ms 0 KB -