結果

問題 No.294 SuperFizzBuzz
ユーザー mamekin
提出日時 2016-04-07 22:52:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,266 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 109,372 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-10 23:54:23
合計ジャッジ時間 2,029 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
int main()
{
int n;
cin >> n;
vector<vector<vector<int> > > dp(1, vector<vector<int> >(2, vector<int>(3, 0)));
dp[0][1][1] = 1;
for(;;){
vector<vector<int> > nextDp(2, vector<int>(3, 0));
for(int i=0; i<2; ++i){
for(int j=0; j<3; ++j){
nextDp[0][j] += dp.back()[i][j];
nextDp[1][(j+1)%3] += dp.back()[i][j];
}
}
dp.push_back(nextDp);
int tmp = nextDp[0][0] + nextDp[1][0];
if(tmp < n)
n -= tmp;
else
break;
}
int a = 0;
for(int i=dp.size()-1; i>=0; --i){
if(n <= dp[i][0][a]){
cout << 3;
}
else{
cout << 5;
n -= dp[i][0][a];
a = (a + 2) % 3;
}
}
cout << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0