結果

問題 No.719 Coprime
ユーザー tumuztumuz
提出日時 2023-10-20 13:24:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,116 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 216,020 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 13:24:37
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
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 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 dame { putsn("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; }
#define kotae cout<<ans<<endl;

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;
  vector<set<int>> mx(11);

  int ans=0;
  int s=1<<11;
  vi dp(s,-1);
  dp[0]=0;
  for(int i=2;i<=n;i++){
    int b=-1;
    rep(j,11) if(i%p[j]==0) b=j;
    if(b!=-1) mx[b].insert(i);
    else dp[0]+=i; 
  }

  rep(i,11){
    vi ndp=dp;
    rep(j,s){
      if(j>(1<<i)-1) continue;
      for(int k:mx[i]){
        bool ok=true;
        rep(l,i) if((j>>l)&1 && k%p[l]==0) ok=false;
        if(ok) {
          int a=0;
          rep(l,i+1) if(k%p[l]==0) a+=(1<<l);
          if(ndp[j]!=-1) chmax(dp[j+a],ndp[j]+k);
          chmax(ans,dp[j+a]);
        }
      }
    }
  }

  kotae;

  return 0;
}
0