結果
問題 |
No.294 SuperFizzBuzz
|
ユーザー |
|
提出日時 | 2019-09-25 16:37:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 365 ms / 5,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 590 ms |
コンパイル使用メモリ | 68,476 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 08:18:35 |
合計ジャッジ時間 | 3,273 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; ll comb(int n, int c){ ll ret = 1; for(int i = 0; i < c; i++){ ret *= (n-i); ret /= i+1; } return ret; } int main(){ int n; cin >> n; n--; int len = 3; while(true){ ll tmp = 0; for(int five = 2; five+1 <= len; five += 3){ tmp += comb(len-1, five); } if(n < tmp) break; n -= tmp; len++; } for(int i = 0; i < 1<<(len-1); i++){ int popcnt = 0; for(int j = 0; j < len-1; j++){ if((i>>j)&1) popcnt++; } if(popcnt%3 == 2){ n--; if(n < 0){ string ret = "5"; for(int j = 0; j < len-1; j++){ ret += "35"[(i>>j)&1]; } reverse(ret.begin(), ret.end()); cout << ret << endl; return 0; } } } }