結果

問題 No.719 Coprime
ユーザー startcppstartcpp
提出日時 2016-07-02 23:15:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 563 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 54,232 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-20 06:21:21
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,448 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 7 ms
5,376 KB
testcase_28 AC 8 ms
5,376 KB
testcase_29 AC 12 ms
5,376 KB
testcase_30 AC 16 ms
5,376 KB
testcase_31 AC 18 ms
5,376 KB
testcase_32 AC 21 ms
5,376 KB
testcase_33 AC 25 ms
5,376 KB
testcase_34 AC 27 ms
5,376 KB
testcase_35 AC 42 ms
5,376 KB
testcase_36 AC 51 ms
5,376 KB
testcase_37 AC 59 ms
5,376 KB
testcase_38 AC 67 ms
5,376 KB
testcase_39 AC 103 ms
5,376 KB
testcase_40 AC 112 ms
5,376 KB
testcase_41 TLE -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

//WAかTLE
#include <iostream>
using namespace std;

int n;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int dfs(int num, long long used) {
	if (num > n) {
		return 0;
	}
	
	int ret = dfs(num + 1, used);	//数字numを使わない場合
	int i;
	
	for (i = 2; i < num; i++) {
		if ((used >> i) % 2 == 1 && gcd(i, num) >= 2) {
			break;
		}
	}
	if (i == num) {
		//数字numを使う場合
		ret = max(ret, num + dfs(num + 1, used + (1LL << num)));
	}
	return ret;
}

signed main() {
	cin >> n;
	cout << dfs(2, 0) << endl;
	return 0;
}
0