結果

問題 No.719 Coprime
ユーザー snrnsidysnrnsidy
提出日時 2021-07-15 15:15:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 201,020 KB
実行使用メモリ 11,868 KB
最終ジャッジ日時 2023-09-17 21:31:57
合計ジャッジ時間 28,210 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,580 KB
testcase_01 AC 8 ms
11,680 KB
testcase_02 AC 10 ms
11,568 KB
testcase_03 AC 11 ms
11,680 KB
testcase_04 AC 12 ms
11,668 KB
testcase_05 AC 13 ms
11,544 KB
testcase_06 AC 16 ms
11,556 KB
testcase_07 AC 17 ms
11,748 KB
testcase_08 AC 18 ms
11,608 KB
testcase_09 AC 19 ms
11,576 KB
testcase_10 AC 21 ms
11,576 KB
testcase_11 AC 22 ms
11,548 KB
testcase_12 AC 23 ms
11,596 KB
testcase_13 AC 25 ms
11,584 KB
testcase_14 AC 26 ms
11,592 KB
testcase_15 AC 27 ms
11,528 KB
testcase_16 AC 28 ms
11,552 KB
testcase_17 AC 29 ms
11,608 KB
testcase_18 AC 32 ms
11,548 KB
testcase_19 AC 33 ms
11,584 KB
testcase_20 AC 34 ms
11,680 KB
testcase_21 AC 36 ms
11,552 KB
testcase_22 AC 37 ms
11,532 KB
testcase_23 AC 39 ms
11,532 KB
testcase_24 AC 39 ms
11,812 KB
testcase_25 AC 41 ms
11,576 KB
testcase_26 AC 43 ms
11,720 KB
testcase_27 AC 43 ms
11,580 KB
testcase_28 AC 45 ms
11,580 KB
testcase_29 AC 47 ms
11,564 KB
testcase_30 AC 48 ms
11,556 KB
testcase_31 AC 50 ms
11,580 KB
testcase_32 AC 50 ms
11,532 KB
testcase_33 AC 51 ms
11,540 KB
testcase_34 AC 54 ms
11,652 KB
testcase_35 AC 54 ms
11,860 KB
testcase_36 AC 56 ms
11,804 KB
testcase_37 AC 57 ms
11,592 KB
testcase_38 AC 58 ms
11,536 KB
testcase_39 AC 60 ms
11,648 KB
testcase_40 AC 62 ms
11,756 KB
testcase_41 AC 87 ms
11,536 KB
testcase_42 AC 96 ms
11,832 KB
testcase_43 AC 174 ms
11,608 KB
testcase_44 AC 206 ms
11,528 KB
testcase_45 AC 222 ms
11,540 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 TLE -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector <int> prime = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};
int dp[2][1<<20];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	
	cin >> N;
	
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<(1<<20);j++)
		{
			dp[i][j] = -1e9;
		}
	}
	
	dp[1][0] = 0;
	
	for(int i=1;i<N;i++)
	{
		memcpy(dp[0],dp[1],sizeof(dp[1]));
		fill(dp[1],dp[1]+(1<<20),-1e9);
		int bitmask = 0;
		for(int j=0;j<20;j++)
		{
			if(((i+1)%prime[j])==0)
			{
				bitmask += (1<<j);
			}
		}
		//cout << i+1 << ' ' << bitmask << '\n';
		for(int j=0;j<(1<<20);j++)
		{
			if(dp[0][j]<=-1e9) continue;
			dp[1][j] = max(dp[1][j],dp[0][j]);
			if((j&bitmask)) continue;
			dp[1][bitmask + j] = max(dp[1][bitmask + j],dp[0][j] + (i+1));
		}
	}
	
	int res = 0;
	
	for(int j=0;j<(1<<20);j++)
	{
		res = max(res,dp[1][j]);
	}
	
	cout << res << '\n';
	
	return 0;
}
0