結果
| 問題 | No.1463 Hungry Kanten |
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-04-02 21:31:02 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 778 ms / 2,000 ms |
| コード長 | 971 bytes |
| 記録 | |
| コンパイル時間 | 3,138 ms |
| コンパイル使用メモリ | 270,572 KB |
| 実行使用メモリ | 117,688 KB |
| 最終ジャッジ日時 | 2026-06-19 09:37:43 |
| 合計ジャッジ時間 | 7,067 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#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;
}
沙耶花