結果
| 問題 |
No.294 SuperFizzBuzz
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2015-10-23 23:52:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 116 ms / 5,000 ms |
| コード長 | 1,014 bytes |
| コンパイル時間 | 696 ms |
| コンパイル使用メモリ | 56,052 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 04:04:32 |
| 合計ジャッジ時間 | 1,945 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
#define LL long long
LL gcd(LL a,LL b){
return (b==0)?a:gcd(b,a%b);
}
LL calc(LL d){
LL res=0;
LL up=1;
LL down=1;
for(LL i = 1; i <= d; i++){
up*=d-i+1;
down*=i;
LL k=gcd(up,down);
up/=k;
down/=k;
if(i%3==2)
res+=up/down;
}
return res;
}
int main() {
LL N;
cin>>N;
LL d=2;
LL prev=0;
while(true){
LL now=calc(d);
// cout<<now<<endl;
if(prev+now>=N)break;
prev+=now;
d++;
}
int cnt=0;
//printf("prev=%lld,d=%lld\n",prev,d);
for(int bit=0;bit<(1<<d);bit++){
if(__builtin_popcount(bit)%3==2){
cnt++;
prev++;
if(prev==N){
for(int i=d-1;i>=0;i--){
int k=((((bit>>i)&1)==1)?5:3);
cout<<k;
}
}
}
}
cout<<5<<endl;
return 0;
}
btk