結果

問題 No.719 Coprime
ユーザー tumuztumuz
提出日時 2023-10-20 09:21:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,954 bytes
コンパイル時間 2,231 ms
コンパイル使用メモリ 208,852 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 09:21:40
合計ジャッジ時間 5,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 4 ms
4,348 KB
testcase_24 AC 5 ms
4,348 KB
testcase_25 AC 5 ms
4,348 KB
testcase_26 AC 5 ms
4,348 KB
testcase_27 AC 5 ms
4,348 KB
testcase_28 AC 5 ms
4,348 KB
testcase_29 AC 5 ms
4,348 KB
testcase_30 AC 5 ms
4,348 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 5 ms
4,348 KB
testcase_33 AC 5 ms
4,348 KB
testcase_34 AC 6 ms
4,348 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
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 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);
  for(int i=32;i<=n;i++){
    bool ok=true;
    rep(j,11) if(i%p[j]==0) ok=false;
    if(ok) dp[0]+=i;
  }
  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;
}
0