結果

問題 No.719 Coprime
ユーザー startcppstartcpp
提出日時 2016-07-02 23:19:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 55,124 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-04-20 06:22:48
合計ジャッジ時間 10,381 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 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 1 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 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 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 2 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 6 ms
5,376 KB
testcase_28 AC 7 ms
5,376 KB
testcase_29 AC 11 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
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
//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 + (1 << num)));
    }
    return ret;
}

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