Submission #5026229


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
struct edge { int to, cost; };
int n, q, a[25], ans;
set<int>st;
signed main() {
	cin >> n >> q;
	rep(i, q)cin >> a[i];
	rep(i, (1 << q)) {
		int cnt = 1;
		rep(j, q) {
			if ((i >> j) & 1)cnt *= a[j];
			if (cnt > n)goto out;
		}
		int memo = cnt;
		rep(j, q)if (memo % a[j] == 0)memo /= a[j];
		if (memo == 1)st.insert(cnt);
	out:;
	}
	cout << st.size() << endl;
	return 0;
}

Submission Info

Submission Time
Task B - Division 2
User anmichi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 703 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:2: error: jump to label ‘out’ [-fpermissive]
  out:;
  ^
./Main.cpp:22:21: note:   from here
    if (cnt > n)goto out;
                     ^
./Main.cpp:24:7: note:   crosses initialization of ‘long long int memo’
   int memo = cnt;
       ^