結果

問題 No.294 SuperFizzBuzz
コンテスト
ユーザー kurenaif
提出日時 2016-06-08 21:26:14
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 649 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 618 ms
コンパイル使用メモリ 82,656 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-25 06:16:03
合計ジャッジ時間 2,166 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from main.cpp:6:
In member function 'std::bitset<_Nb>::reference::operator bool() const [with long unsigned int _Nb = 36]',
    inlined from 'int main()' at main.cpp:37:15:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bitset:926:28: warning: 'res' may be used uninitialized [-Wmaybe-uninitialized]
  926 |         { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
      |                  ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp: In function 'int main()':
main.cpp:19:13: note: 'res' was declared here
   19 |         ull res;
      |             ^~~

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <ciso646>
#include <bitset>

using namespace std;

#define ull unsigned long long

int main(void) {

	int N; cin >> N;
	int M = 32;

	int count = 0;

	ull res;
	int m;
	for (m = 1; m < M; ++m) {
		unsigned long long u = 0;
		for (ull i = 0; i < (1 << (m-1)); ++i) {
			ull tar = i << 1; tar += 1;
			if (bitset<36>(tar).count() % 3 == 0) ++count;
			if (count == N) {
				res = tar;
				break;
			}
		}
		if (count == N) break;
	}

	bitset<36> b = res;

	for (int i = m-1; i >= 0; --i) {
		cout << (b[i] ? 5 : 3);
	}
	cout << endl;
	system("pause");

	return 0;
}
0