結果

問題 No.294 SuperFizzBuzz
ユーザー tsutaj
提出日時 2017-10-10 00:47:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,797 bytes
コンパイル時間 901 ms
コンパイル使用メモリ 100,404 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 07:12:32
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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

//
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;
const int S = 25;
int N;
int dp[S+1][2][3];
signed main() {
cin >> N;
dp[1][1][2] = 1;
rep(i,0,S) rep(j,0,2) rep(k,0,3) {
rep(s,0,2) {
int y = (s == 0 ? 3 : 5);
int nk = (k + y) % 3;
dp[i+1][s][nk] += dp[i][j][k];
}
}
int sum = N, M = 0;
repq(i,1,S) {
int vl = dp[i][0][0];
int vr = dp[i][1][0];
if(sum > vl + vr) sum -= vl + vr;
else {
M = i;
break;
}
}
string ans = "";
int mo = 0;
repr(i,M,1) {
int vl = dp[i][0][mo];
if(sum > vl) {
ans += "5";
mo = (mo + 1) % 3;
sum -= vl;
}
else ans += "3";
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0