結果
| 問題 |
No.1463 Hungry Kanten
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-02 22:09:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,554 bytes |
| コンパイル時間 | 4,668 ms |
| コンパイル使用メモリ | 247,560 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-23 23:36:09 |
| 合計ジャッジ時間 | 7,825 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 RE * 18 |
ソースコード
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define itr(x,c) for(auto x=c.begin();x!=c.end();x++)
#define ritr(x,c) for(auto x=c.rbegin();x!=c.rend();x++)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const double PI=acos(-1);
static const double eps=1e-10;
//static const ll MOD=998244353;
//for(i=0;i<N;i++)cin>>a[i];
typedef vector<ll> v1d;
typedef vector<v1d> v2d;
typedef vector<v2d> v3d;
typedef vector<v3d> v4d;
v1d eratos(ll N) {
v1d primes;
v1d isp(N+5,1);
isp[0]=isp[1]=0;
ll i,j;
for(i=2; i*i<=N; i++) {
if(isp[i]==0) continue;
for(j=i+i; j<=N; j+=i)
isp[j]=0;
}
for(i=0; i<=N; i++)
if(isp[i]) primes.push_back(i);
return primes;
}
template <typename T>
struct PrimeFact {
vector<T> spf;
PrimeFact(T N) { init(N); }
void init(T N) { // 前処理。spf を求める
spf.assign(N + 1, 0);
for (T i = 0; i <= N; i++) spf[i] = i;
for (T i = 2; i * i <= N; i++) {
if (spf[i] != i) continue;
for (T j = i + i; j <= N; j += i) {
spf[j] = i;
}
}
}
map<T, T> get(T n) { // nの素因数分解を求める
map<T, T> m;
while (n != 1) {
m[spf[n]]++;
n /= spf[n];
}
return m;
}
};
int main(void) {
ll i,j,k;
/*
ll N;cin>>N;
v1d a(N);
for(i=0;i<N;i++)cin>>a[i];
*/
v1d pri=eratos(1000);
map<ll,ll> dic;
i=0;
for(auto p:pri){
dic[p]=i;i++;
}
PrimeFact<ll> pf(1000);
ll N,K;cin>>N>>K;
v1d a(N);
v2d f(N,v1d(pri.size(),0));
for(i=0;i<N;i++){
cin>>a[i];
map<ll,ll> mp=pf.get(a[i]);
itr(it,mp) f[i][dic[it->first]]=it->second;
}
set<v1d> st;
for(ll S=0;S<1<<N;S++){
if(__builtin_popcountll(S)<K) continue;
ll t=0;
for(i=0;i<N;i++) if(S>>i&1)t+=a[i];
map<ll,ll> mp=pf.get(t);
v1d v(pri.size(),0);
itr(it,mp) v[dic[it->first]]=it->second;
st.insert(v);
v1d cnt(pri.size(),0);
v1d u;
for(i=0;i<N;i++)if(S>>i&1)u.push_back(i);
for(auto c:u){
for(auto p:pri){
cnt[dic[p]]+=f[c][dic[p]];
}
}
st.insert(cnt);
}
pt(st.size());
}