Submission #56940

# Submission time Handle Problem Language Result Execution time Memory
56940 2018-07-13T09:04:23 Z polyfish Sažetak (COCI17_sazetak) C++14
64 / 160
500 ms 652 KB
//I love armpit fetish

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

const int MAX_M = 12;

int n, m, k[MAX_M];

void enter() {
	cin >> n >> m;
	for (int i=1; i<=m; ++i)
		cin >> k[i];
	k[++m] = n;
}

int solve() {
	int res = 0;
	for (int i=1; i<=n; ++i) {
		bool ok1 = false, ok2 = false;
		for (int j=1; j<=m; ++j) {
			ok1 = ok1 || (i%k[j]==0);
			ok2 = ok2 || (i%k[j]==1);
			if (ok1 && ok2)
				break;
		}
		res += (ok1 && ok2);
	}
	return res;
}

int main() {
	//#define OFFLINE_JUDGE doraemon
	#ifdef OFFLINE_JUDGE
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	enter();
	cout << solve();
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 3 ms 360 KB Output is correct
3 Correct 171 ms 472 KB Output is correct
4 Correct 209 ms 652 KB Output is correct
5 Execution timed out 1068 ms 652 KB Time limit exceeded
6 Execution timed out 1070 ms 652 KB Time limit exceeded
7 Execution timed out 1065 ms 652 KB Time limit exceeded
8 Execution timed out 1082 ms 652 KB Time limit exceeded
9 Execution timed out 1076 ms 652 KB Time limit exceeded
10 Execution timed out 1063 ms 652 KB Time limit exceeded