結果

問題 No.638 Sum of "not power of 2"
ユーザー ldsybldsyb
提出日時 2018-02-11 00:59:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 410 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 156,012 KB
最終ジャッジ日時 2023-08-06 17:18:38
合計ジャッジ時間 1,995 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:7:24: エラー: the type ‘const main()::<ラムダ(int64_t)>’ of ‘constexpr’ variable ‘bitcount’ is not literal
    7 |         constexpr auto bitcount = [](int64_t x) {
      |                        ^~~~~~~~
main.cpp:7:36: 備考: ‘main()::<ラムダ(int64_t)>’ is not literal because:
    7 |         constexpr auto bitcount = [](int64_t x) {
      |                                    ^
cc1plus: 備考:   ‘main()::<ラムダ(int64_t)>’ is a closure type, which is only literal in C++17 and later

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int64_t n;
	cin >> n;
	constexpr auto bitcount = [](int64_t x) {
		int r = 0;
		for (; x; x >>= 1) {
			if (x & 1) {
				r++;
			}
		}
		return r;
	};
	for (int64_t a = 3; a < 500; a++) {
		int64_t b = n - a;
		if (0 < b && 1 < bitcount(a) && 1 < bitcount(b)) {
			cout << a << ' ' << b << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}
0