結果

問題 No.294 SuperFizzBuzz
ユーザー Yang33
提出日時 2016-10-18 01:47:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 427 ms / 5,000 ms
コード長 1,956 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 14:28:50
合計ジャッジ時間 3,612 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX
using namespace std;
#define FOR(i,s,e) for(int (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(int (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl
llong n;
llong comb[31][31];
void calcomb() {
int i, j;
for (i = 0; i <= 30; i++) {
for (j = 0; j <= i; j++) {
if (j == 0 || j == i)
comb[i][j] = 1;
else
comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
}
}
}
llong exsum(int a) {
llong ans = 0;
FOR(i, 0, a) {
if ((i + 1) % 3 == 0) {
ans += comb[a - 1][i];
}
}
return ans;
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> n;
calcomb();
llong count = 0;
/* */
int keta;
FOR(i, 0, 26) {
keta = i;
count += exsum(keta);
if (count >= n) {
break;
}
}
count = n - (count - exsum(keta));
int cc = 0;
string ans="";
/* 01 */
FOR(bit, 1, (1 << keta + 1)) {
int num = bit;
int check3 = 0;
while (num != 0) {
/* 3 */
if (num & 1)
check3++;
num = num >> 1;
}
/* */
if (!(bit & 1))
continue;
if (check3 % 3 != 0)
continue;
cc++;
if (cc == count) {
FORR(i,keta-1,-1) {
if (bit&(1 << i))
ans += "5";
else ans += "3";
}
cout << ans << endl;
return 0;
}
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0