E - Factorial Divisibility CodeForces - 1754D

哆啦A梦传送门

理解下面就可以理解代码

就是: x!=(x-1)!*x

设:x1==x! x2==(x-1)! x3==x

(设这些就是为了好描述)

然后就是如果x3==x 我们就可以合成x!如果x3==2*x 我们就可以生成两个x! 但是我们如果x3不是x的整数倍就不能被x!整除 ,所以我们就低阶一直向上走


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
using namespace std;
const int M=5e5+10;
const int inf=0x3f3f3f3f;
int a[M];
void sol()
{
    int n,x;
    cin>>n>>x;
    for(int i=1;i<=n;i++)
    {
        int t;
        cin>>t; a[t]++;
    }
    for(int i=1;i<x;i++)
    {
        if(a[i]%(i+1))
        {
            no; return ;
        }
        else
        {
            a[i+1]+=a[i]/(i+1);
        }
    }
    yes;
    return ;
}
signed main()
{
    ios;
    int t=1;
//    cin>>t;
    while(t--)
    {
        sol();
    }
    return 0;
}



(我感觉我的表达能力不够强,大家凑活着看看吧)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

活在当下 北乔

不爱多bb,朴实一句话:感谢您

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值