Submission #48358
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include <stdio.h> #include <stdint.h> uint64_t x; uint64_t n; uint64_t a[2 * 100005]; uint64_t bits[65]; uint64_t ans; int main() { scanf ( "%llu" , &n); for (uint64_t i = 1; i <= n; i++) { scanf ( "%llu" , &a[i]); uint64_t tmp = a[i]; uint64_t j = 0; while (tmp) { bits[j] += tmp & 1llu; j++; tmp >>= 1; } } uint64_t mask = 1; for (uint64_t i = 0; i < 32; i++) { if ((n - bits[i]) > bits[i]) { x |= mask; } mask <<= 1; } for (uint64_t i = 1; i <= n; i++) { ans += (x ^ a[i]); } printf ( "%llu\n" , ans); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1117 - Xor JAPAN |
ユーザー名 | ei1710 |
投稿日時 | 2019-04-22 16:42:53 |
言語 | C |
状態 | Accepted |
得点 | 10 |
ソースコード長 | 882 Byte |
最大実行時間 | 50 ms |
最大メモリ使用量 | 2104 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 10 / 10 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in_1.txt | AC | 27 ms | 504 KB |
1
|
in_2.txt | AC | 33 ms | 1080 KB |
1
|
in_3.txt | AC | 33 ms | 1180 KB |
1
|
in_4.txt | AC | 24 ms | 696 KB |
1
|
in_5.txt | AC | 38 ms | 1736 KB |
1
|
in_6.txt | AC | 41 ms | 2052 KB |
1
|
in_7.txt | AC | 41 ms | 2076 KB |
1
|
in_8.txt | AC | 41 ms | 2104 KB |
1
|
in_9.txt | AC | 50 ms | 2008 KB |
1
|
in_10.txt | AC | 43 ms | 1808 KB |
1
|
in_11.txt | AC | 18 ms | 304 KB |
1
|
sample_in.txt | AC | 27 ms | 404 KB |
1
|