結果

問題 No.719 Coprime
ユーザー heno239heno239
提出日時 2018-10-25 21:16:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,414 bytes
コンパイル時間 2,375 ms
コンパイル使用メモリ 108,880 KB
実行使用メモリ 114,256 KB
最終ジャッジ日時 2024-04-29 21:41:53
合計ジャッジ時間 7,303 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,144 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 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 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 4 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 6 ms
5,376 KB
testcase_27 AC 7 ms
5,376 KB
testcase_28 AC 9 ms
5,376 KB
testcase_29 AC 13 ms
5,376 KB
testcase_30 AC 17 ms
5,376 KB
testcase_31 AC 24 ms
5,376 KB
testcase_32 AC 30 ms
5,376 KB
testcase_33 AC 37 ms
5,376 KB
testcase_34 AC 43 ms
5,376 KB
testcase_35 AC 52 ms
5,376 KB
testcase_36 AC 68 ms
5,376 KB
testcase_37 AC 85 ms
5,376 KB
testcase_38 AC 104 ms
5,376 KB
testcase_39 AC 130 ms
5,376 KB
testcase_40 AC 165 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 #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int deq[1263]; int t;
int ma; int n;
bool check(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	if (a == 1)return true;
	else return false;
}
void dfs(int num, int sum) {
	if (num == n + 1)return;
	bool valid = true;
	rep(i, t)if (!check(num, deq[i]))valid = false;
	ma = max(ma, sum);
	dfs(num + 1, sum);
	if (valid) {
		ma = max(ma, sum + num);
		deq[t] = num; t++;
		dfs(num + 1, sum + num);
		t--;
	}
}
int main() {
	cin >> n; dfs(2,0); cout << ma << endl;
	return 0;
}
0