HzuWHF


私信TA

用户名:I7I08I9047

访问量:76511

签 名:

我RUN了

等  级
排  名 18
经  验 20469
参赛次数 13
文章发表 127
年  龄 3
在职情况 学生
学  校 贺州学院
专  业

  自我简介:



参考代码:

#include<bits/stdc++.h>
constexpr auto Inf = 0x3F3F3F3F;
#define Loc freopen("baka.in", "r", stdin)
typedef long long LL;
using namespace std;

const int SIZE = 1E4 + 7;
vector<int> vec;
bool Vis[SIZE];

int Gcd(int A, int B) {
	return !B ? A : Gcd(B, A % B);
}

int main() {
	ios::sync_with_stdio(false);
	int Tot; cin >> Tot;
	for (int pos = 1, Tmp; pos <= Tot; pos++)
		cin >> Tmp, vec.push_back(Tmp);
	int Judg = *vec.begin();
	for (int pos = 1; pos < vec.size(); pos++)
		Judg = Gcd(Judg, vec[pos]);
	if (Judg != 1) {
		puts("INF"); return 0;
	} Vis[0] = true;
	for (int pos = 0; pos < vec.size(); pos++)
		for (int Ind = 0; Ind + vec[pos] < SIZE; Ind++) {
			if (Vis[Ind])
				Vis[Ind + vec[pos]] = true;
		}
	int ans = 0;
	for (int pos = 0; pos < SIZE; pos++)
		ans += !Vis[pos];
	cout << ans << endl;
}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区