답안 #741671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741671 2023-05-14T14:17:01 Z jongjip Intercastellar (JOI22_ho_t1) C
0 / 100
1 ms 212 KB
#include <stdio.h>
#define max(a, b) (((a)>(b))?(a):(b))

#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4996)

unsigned long long a[1020406];
unsigned long long x[1020406];
unsigned long long aa[1020406];

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 count = 0;
    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:5: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    5 | #pragma warning(disable: 4996)
      | 
Main.c: In function 'main':
Main.c:22:24: warning: unused variable 'count' [-Wunused-variable]
   22 |     unsigned long long count = 0;
      |                        ^~~~~
Main.c:23:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &n);
      |     ^~~~~~~~~~~~~~~
Main.c:25:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%lld", &a[i]);
      |         ^~~~~~~~~~~~~~~~~~~~
Main.c:27:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     scanf("%d", &q);
      |     ^~~~~~~~~~~~~~~
Main.c:29:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%lld", &x[i]);
      |         ^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -