結果

問題 No.294 SuperFizzBuzz
ユーザー startcppstartcpp
提出日時 2015-10-24 00:12:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,045 ms / 5,000 ms
コード長 527 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 52,136 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 04:59:14
合計ジャッジ時間 7,640 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1,045 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 51 ms
4,348 KB
testcase_09 AC 567 ms
4,348 KB
testcase_10 AC 567 ms
4,352 KB
testcase_11 AC 958 ms
4,376 KB
testcase_12 AC 995 ms
4,352 KB
testcase_13 AC 1,018 ms
4,352 KB
testcase_14 AC 1,044 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

void output( int n, int i ){
	for( int j = n - 1; j >= 0; j-- ){
		cout << (((i >> j) % 2) ? 5 : 3);
	}
	cout << endl;
}

int main()
{
	int x;
	cin >> x;
	x--;
	
	int n;
	for( int n = 1; n < 26; n++ ){
		for( int i = 0; i < (1 << n); i++ ){
			if( i % 2 == 0 )
				continue;
			int digitSum = 0;
			for( int j = 0; j < n; j++ )
				digitSum += (((i >> j) % 2) ? 5 : 3);
			if( digitSum % 3 == 0 ){
				if( !x ){
					output(n, i);
					return 0;
				}
				x--;
			}
		}
	}
	return 0;
}
0