結果

問題 No.294 SuperFizzBuzz
ユーザー chuka231
提出日時 2015-10-23 23:25:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 59,284 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-07-23 17:54:07
合計ジャッジ時間 7,045 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1 TLE * 1
other -- * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <cstring>
#include <stack>
using namespace std;

void add(string &s)
{
	for (int i = s.size()-2; i > 0; i--) {
		if (s[i] == '5' && s[i - 1] == '3') {
			s[i] = '3';
			s[i - 1] = '5';
			return;
		}
	}

	for (int i = s.size() - 2; i > 1; i--) {
		if (s[i] == '3' && s[i - 1] == '3' && s[i - 2] == '3') {
			s[i] = '5';
			s[i - 1] = '5';
			s[i - 2] = '5';
			return;
		}
	}

	s = "3" + s;
}

int main()
{
	int n;
	cin >> n;

	string s = "555";

	for (int i = 1; i < n; i++) add(s);

	cout << s << endl;
	//getchar(); getchar();
	return 0;
}
0