結果
問題 |
No.737 PopCount
|
ユーザー |
![]() |
提出日時 | 2018-10-01 15:18:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 712 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-10-12 09:48:00 |
合計ジャッジ時間 | 2,853 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 5 TLE * 1 -- * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%ld", &a); | ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h> long popcount(long bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >>16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >>32 & 0x00000000ffffffff); } int main() { long a; scanf("%ld", &a); long sum=0; for (long i = a; i != 0; i--) { sum = (sum + (i * popcount(i)) % 1000000007) % 1000000007; } printf("%ld", sum); return 0; }