結果
問題 | No.294 SuperFizzBuzz |
ユーザー |
![]() |
提出日時 | 2016-10-14 19:43:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 647 ms / 5,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 69,760 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 06:50:20 |
合計ジャッジ時間 | 5,288 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <iostream>#include <string>#include <queue>using namespace std;//最大25桁 longlong 19桁 ⇒ bitでの計算//3桁 3:0個 4桁 3:1個 5桁 3:2個 ・・・//全探索 2^25 ⇒ 可int main() {int N, c = 0; cin >> N;int sum;//i : シフト数for (int i = 0; ; i++) {// n : i-1桁の2進数の値for (int n = 0; n < (1 << i);n++) {if (!(n & 1)) continue;sum = 0;//各桁の5の和を求めるfor (int j = 0; j < i;j++) {if (n&(1 << j)) {sum += 5;}}if (sum % 3 == 0) {c++;if (c == N) {string Ans;for (int k = i-1; k >= 0; k--) {if (n&(1 << k)) {Ans += "5";}else {Ans += "3";}}cout << Ans << endl; return 0;}}}}}