Codeforces Round #829 (Div. 2) D Factorial Divisibility
Factorial Divisibility
模拟
合....合成大西瓜?
枚举每个阶乘因子,提取公因式之后有很多散着的 \(1\),然后判断能不能合成当前倍数
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
const ll maxn = 2e5 + 10;
const ll inf = 1e17 + 10;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vector<int>vis(500001, 0);
int n, m;
cin >> n >> m;
int minn = 1e9;
for(int i=0; i<n; i++)
{
int x;
cin >> x;
minn = min(minn, x);
vis[x]++;
}
int f = 1, now = 0;
for(int i=1; i<=m; i++)
{
if(now % i) f = 0;
now /= i;
now += vis[i];
}
if(f) cout << "Yes\n";
else cout << "No\n";
cout << endl;
return 0;
}