結果
| 問題 |
No.719 Coprime
|
| コンテスト | |
| ユーザー |
tumuz
|
| 提出日時 | 2023-10-14 11:54:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,847 bytes |
| コンパイル時間 | 1,855 ms |
| コンパイル使用メモリ | 198,132 KB |
| 最終ジャッジ日時 | 2025-02-17 07:47:25 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 WA * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(),(x).end()
#define Q2 1000000007
#define Q 998244353
#define lINF LONG_LONG_MAX //ll
#define iINF INT_MAX //int
#define yes "Yes"
#define no "No"
#define kotae cout<<ans<<endl;
#define dame { puts("0"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
using ll=long long;
using ull=unsigned long long;
using P=pair<int,int>;
using pqg=priority_queue<int,vector<int>,greater<int>>;
using vi=vector<int>;
using vi2=vector<vector<int>>;
using vi3=vector<vector<vector<int>>>;
using vl=vector<ll>;
using vl2=vector<vector<ll>>;
using vl3=vector<vector<vector<ll>>>;
using vs=vector<string>;
using vp=vector<P>;
using vp2=vector<vector<P>>;
void chmax(int &x, int y){ x=max(x,y); return; }
void chmin(int &x, int y){ x=min(x,y); return; }
void chmaxl(ll &x, ll y){ x=max(x,y); return; }
void chminl(ll &x, ll y){ x=min(x,y); return; }
struct Prime{
vi ps;
set<ll> st;
vector<bool> p;
vector<int> devisor;
Prime(int n){
p.resize(n+1,true);
devisor.resize(n+1);
for(int i=2;i<=n;i++){
if(!p[i]) continue;
ps.push_back(i);
st.insert(i);
for(int j=i;j<=n;j+=i) {
p[j]=false;
devisor[j]=i;
}
}
}
bool isPrime(int n){
if(st.count(n)) return true;
else return false;
}
};
int main() {
int p[]={2,3,5,7,11,13,17,19,23,29,31};
int n;
cin >> n;
int ans=0;
int s=1<<11;
vi dp(s);
rep(i,s){
for(int j=2;j<=n;j++){
bool ok=true;
rep(k,11) if((i>>k)&1 && j%p[k]==0) ok=false;
if(ok) {
int a=0;
rep(k,11) if(j%p[k]==0) a+=(1<<k);
chmax(dp[i+a],dp[i]+j);
chmax(ans,dp[i+a]);
}
}
}
kotae;
return 0;
}
tumuz