Submission #5030293
Source Code Expand
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int x) {
for (int i = 2; i * i <= x; i++) {
if (x % i == 0)return false;
}
return x > 1;
}
int gcd(int x, int y) {
if (y == 0)return x;
return gcd(y, x % y);
}
int lcm(int x, int y) {
return x * y / gcd(x, y);
}
int kai(int x) {
if (x == 0)return 1;
return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
int res = 1;
while (y > 0) {
if (y & 1) {
res = res * x % mod;
}
x = x * x % mod;
y >>= 1;
}
return res;
}
int comb(int x, int y) {
return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/
int n, m, a[30];
set<int>st;
signed main() {
cin >> m >> n;
rep(i, n)cin >> a[i];
rep(i, 1 << n) {
int an = 1, ans;
rep(j, n) {
if ((i >> j) & 1)an *= a[j];
if (an > m)goto ng;
}
ans = an;
rep(j, n) {
if (an % a[j] == 0)an /= a[j];
}
if (an == 1)st.insert(ans);
ng:;
}
cout << st.size() << endl;
}
Submission Info
Submission Time |
|
Task |
B - Division 2 |
User |
define |
Language |
C++14 (GCC 5.4.1) |
Score |
100 |
Code Size |
1531 Byte |
Status |
AC |
Exec Time |
2202 ms |
Memory |
2688 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
Subtask2 |
Score / Max Score |
0 / 0 |
25 / 25 |
75 / 75 |
Status |
|
|
|
Set Name |
Test Cases |
Sample |
sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt |
Subtask1 |
sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub1_5.txt, sub1_6.txt |
Subtask2 |
sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, sub1_1.txt, sub1_2.txt, sub1_3.txt, sub1_4.txt, sub1_5.txt, sub1_6.txt, sub2_1.txt, sub2_2.txt, sub2_3.txt, sub2_4.txt, sub2_5.txt, sub2_6.txt, sub2_7.txt, sub2_8.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_1.txt |
AC |
1 ms |
256 KB |
sample_2.txt |
AC |
1 ms |
256 KB |
sample_3.txt |
AC |
1 ms |
256 KB |
sample_4.txt |
AC |
1 ms |
256 KB |
sub1_1.txt |
AC |
1 ms |
256 KB |
sub1_2.txt |
AC |
1 ms |
256 KB |
sub1_3.txt |
AC |
1 ms |
256 KB |
sub1_4.txt |
AC |
1 ms |
256 KB |
sub1_5.txt |
AC |
2 ms |
256 KB |
sub1_6.txt |
AC |
2 ms |
256 KB |
sub2_1.txt |
AC |
5 ms |
256 KB |
sub2_2.txt |
AC |
5 ms |
384 KB |
sub2_3.txt |
AC |
8 ms |
384 KB |
sub2_4.txt |
AC |
6 ms |
384 KB |
sub2_5.txt |
AC |
184 ms |
640 KB |
sub2_6.txt |
AC |
206 ms |
640 KB |
sub2_7.txt |
AC |
2145 ms |
1152 KB |
sub2_8.txt |
AC |
2202 ms |
2688 KB |