結果

問題 No.294 SuperFizzBuzz
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-08-31 23:29:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 438 ms / 5,000 ms
コード長 1,419 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 21:29:32
合計ジャッジ時間 4,085 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 438 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 20 ms
4,376 KB
testcase_09 AC 268 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 359 ms
4,380 KB
testcase_12 AC 394 ms
4,380 KB
testcase_13 AC 414 ms
4,376 KB
testcase_14 AC 436 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

int main(){
  int d[25] = {
    0,0,1,3,6,11,21,42,85,171,342,683,
    1365,2730,5461,10923,21846,43691,
    87381,174762,349525,699051,1398102,
    2796203,5592405
  };
  int n;
  cin >> n;
  int k = 0;
  rep(i,0,25){
    if(n-d[i]<=0){
      k = i;
      break;
    }
    n-=d[i];
  }
  rep(i,0,1<<k){
    int a = 5;
    rep(j,0,k){
      if((i>>j)&1){
        a += 5;
      }
      else{
        a += 3;
      }
    }
    if(a%3==0){
      n--;
      if(n==0){
        string s;
        rep(j,0,k){
          if((i>>j)&1){
            s += "5";
          }
          else{
            s += "3";
          }
        }
        reverse(all(s));
        s+="5";
        cout << s << endl;
        break;
      }
    }
  }
  return 0;
}
0