CF1753B 题解
#
#
定理:
这题就是围绕以上定理展开的。
如果加入一个数 满足 ,则根据定理,将 ,在将 。其中 表示 出现的次数
如果 即满足 。
#
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <cmath>
#include <sstream>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#define x first
#define y second
#define IOS ios::sync_with_stdio(false)
#define cit cin.tie(0)
#define cot cout.tie(0)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int N = 500010, M = 100010, MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int n, x;
int cnt[N];
void solve()
{
cin >> n >> x;
for (int i = 1; i <= n; i ++ )
{
int t;
cin >> t;
cnt[t] ++ ;
while (cnt[t] >= t + 1)
{
cnt[t + 1] += cnt[t] / (t + 1);
cnt[t] %= (t + 1);
t ++ ;
}
}
bool flag = true;
for (int i = 1; i < x; i ++ )
if (cnt[i])
{
flag = false;
break;
}
if (flag) cout << "Yes" << endl;
else cout << "No" << endl;
}
int main()
{
IOS;
cit, cot;
int T = 1;
// cin >> T;
while (T -- ) solve();
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具