参考代码:
#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 人评分
K-进制数 (C++代码)浏览:850 |
钟神赛车 (C语言代码)浏览:870 |
简单的a+b (C语言代码)浏览:573 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:560 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:1067 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1420 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:564 |
简单的a+b (C语言代码)浏览:415 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:1317 |
逆反的01串 (C语言代码)浏览:1436 |