結果
| 問題 |
No.1463 Hungry Kanten
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-04-02 21:31:02 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 971 bytes |
| コンパイル時間 | 25,743 ms |
| コンパイル使用メモリ | 327,368 KB |
| 最終ジャッジ日時 | 2025-01-20 08:21:49 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 TLE * 1 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
vector<int> get(int n){
static vector<vector<int>> dp(20001);
if(dp[n].size()>0)return dp[n];
int c = n;
for(int i=2;i*i<=c;i++){
while(c%i==0){
c /= i;
dp[n].push_back(i);
}
}
if(c!=1)dp[n].push_back(c);
return dp[n];
}
int main(){
int n,k;
cin>>n>>k;
vector<vector<int>> v;
vector<int> a(n);
rep(i,n)cin>>a[i];
rep(i,1<<n){
int c = 0;
rep(j,n){
if((i>>j)&1)c++;
}
if(c<k)continue;
vector<int> M;
int sum = 0;
rep(j,n){
if((i>>j)&1){
sum += a[j];
vector<int> t = get(a[j]);
rep(k,t.size())M.push_back(t[k]);
}
}
v.push_back(get(sum));
sort(M.begin(),M.end());
v.push_back(M);
}
sort(v.begin(),v.end());
v.erase(unique(v.begin(),v.end()),v.end());
cout<<v.size()<<endl;
return 0;
}
沙耶花