結果

問題 No.1463 Hungry Kanten
ユーザー 沙耶花沙耶花
提出日時 2021-04-02 21:31:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,161 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 4,605 ms
コンパイル使用メモリ 268,416 KB
実行使用メモリ 117,568 KB
最終ジャッジ日時 2023-08-25 14:47:47
合計ジャッジ時間 8,448 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 23 ms
5,632 KB
testcase_03 AC 1,161 ms
117,568 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 774 ms
56,504 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,384 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 7 ms
4,384 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 22 ms
5,856 KB
testcase_17 AC 72 ms
10,100 KB
testcase_18 AC 21 ms
5,232 KB
testcase_19 AC 315 ms
26,772 KB
testcase_20 AC 437 ms
36,004 KB
testcase_21 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}

0