結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 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 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 8 ms
5,376 KB
testcase_28 AC 8 ms
5,376 KB
testcase_29 AC 11 ms
5,376 KB
testcase_30 AC 16 ms
5,376 KB
testcase_31 AC 18 ms
5,376 KB
testcase_32 AC 20 ms
5,376 KB
testcase_33 AC 23 ms
5,376 KB
testcase_34 AC 25 ms
5,376 KB
testcase_35 AC 40 ms
5,376 KB
testcase_36 AC 46 ms
5,376 KB
testcase_37 AC 53 ms
5,376 KB
testcase_38 AC 63 ms
5,376 KB
testcase_39 AC 95 ms
5,376 KB
testcase_40 AC 105 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 #

//想定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