結果
| 問題 |
No.294 SuperFizzBuzz
|
| コンテスト | |
| ユーザー |
capythm
|
| 提出日時 | 2015-10-23 23:00:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 565 ms / 5,000 ms |
| コード長 | 653 bytes |
| コンパイル時間 | 577 ms |
| コンパイル使用メモリ | 55,900 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 01:39:45 |
| 合計ジャッジ時間 | 4,530 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
bool judge( int a, int b ){
int sum = 5;
for( int i=0; i<a; i++ ){
if( b & 1 ) sum += 5;
else sum += 3;
b >>= 1;
}
return (sum % 3) == 0;
}
string conv( int a, int b ){
string ret(a+1,'5');
for( int i=0; i<a; i++ ){
if( (b & 1) == 0 ) ret[a-1-i] = '3';
b >>= 1;
}
return ret;
}
int main( void )
{
int n;
cin >> n;
int cnt = 0;
for( int i=1; ; i++ ){
for( int j=0; j<(1LL<<i); j++ ){
if( judge( i, j ) ){
cnt++;
}
if( cnt == n ){
cout << conv( i, j ) << endl;
return 0;
}
}
}
cout << endl;
}
capythm