結果

問題 No.294 SuperFizzBuzz
ユーザー capythmcapythm
提出日時 2015-10-23 23:00:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 597 ms / 5,000 ms
コード長 653 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 52,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 07:24:56
合計ジャッジ時間 4,704 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 597 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 29 ms
4,376 KB
testcase_09 AC 318 ms
4,380 KB
testcase_10 AC 321 ms
4,376 KB
testcase_11 AC 542 ms
4,380 KB
testcase_12 AC 564 ms
4,380 KB
testcase_13 AC 580 ms
4,376 KB
testcase_14 AC 592 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0