当前位置:网站首页>Acwing game 60

Acwing game 60

2022-07-19 13:35:00 leimingzeOuO

AcWing 4494. having dinner

simulation

#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-5;
#define x first
#define y second
#define LL long long 
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(LL a,LL mod){
    return (a%mod+mod)%mod;}
int lowbit(LL x){
    return x&-x;}// Its lowest 1 And behind it 0 The value of composition 
//void read(__int128 &x){char c = getchar();while (c != '-' & (c < '0' | c > '9'))c = getchar();if (c == '-') {c = getchar();while (c >= '0' & c <= '9') {x = x * 10 + c - '0';c = getchar();}x = 0 - x;} else {while (c >= '0' & c <= '9') {x = x * 10 + c - '0';c = getchar();}}}
//void out(__int128 x) {string c = "";while (x) {c += x % 10 + '0';x /= 10;}reverse(c.begin(), c.end());cout << c << endl;}
int qmi(int a, int k, int p){
    int res = 1 % p;while (k){
    if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int _;
int n,m,k;
void solve()
{
    
    cin>>n>>m>>k;
    int h=min(m,k);
    if(h>=n)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
signed main()
{
    
    io;
    //cin>>_; 
    //while(_--)
    solve();
    return 0;
}

4495. Array operation

Double pointer simulated small top reactor

#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-5;
#define x first
#define y second
#define LL long long 
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(LL a,LL mod){
    return (a%mod+mod)%mod;}
int lowbit(LL x){
    return x&-x;}// Its lowest 1 And behind it 0 The value of composition 
//void read(__int128 &x){char c = getchar();while (c != '-' & (c < '0' | c > '9'))c = getchar();if (c == '-') {c = getchar();while (c >= '0' & c <= '9') {x = x * 10 + c - '0';c = getchar();}x = 0 - x;} else {while (c >= '0' & c <= '9') {x = x * 10 + c - '0';c = getchar();}}}
//void out(__int128 x) {string c = "";while (x) {c += x % 10 + '0';x /= 10;}reverse(c.begin(), c.end());cout << c << endl;}
int qmi(int a, int k, int p){
    int res = 1 % p;while (k){
    if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int _;
int n,k;
const int N=1e5+10;
int a[N];
void solve()
{
    
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	int cnt=0;
	for(int i=1,j=1;i<=k;i++)
	{
    
		while(a[j]-cnt<=0&&j<=n)j++;
		if(j<=n&&a[j]-cnt>0)
		{
    
			cout<<a[j]-cnt<<endl;
			cnt+=a[j]-cnt;
		}
		else cout<<0<<endl;
	}
}
signed main()
{
    
    io;
 	//cin>>_; 
 	//while(_--)
    solve();
    return 0;
}

4496. Eat fruit

Combinatorial number

#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-5;
#define x first
#define y second
#define LL long long 
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(LL a,LL mod){
    return (a%mod+mod)%mod;}
int lowbit(LL x){
    return x&-x;}// Its lowest 1 And behind it 0 The value of composition 
//void read(__int128 &x){char c = getchar();while (c != '-' & (c < '0' | c > '9'))c = getchar();if (c == '-') {c = getchar();while (c >= '0' & c <= '9') {x = x * 10 + c - '0';c = getchar();}x = 0 - x;} else {while (c >= '0' & c <= '9') {x = x * 10 + c - '0';c = getchar();}}}
//void out(__int128 x) {string c = "";while (x) {c += x % 10 + '0';x /= 10;}reverse(c.begin(), c.end());cout << c << endl;}
int qmi(int a, int k, int p){
    int res = 1 % p;while (k){
    if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int _;
int n,m,k;
const int mod=998244353;
const int N=2010;
int c[N][N];
void init()
{
    
    for(int i=0;i<=2000;i++)
        for(int j=0;j<=i;j++)
        {
    
             if(!j)c[i][j]=1;
             else c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
        }
}
void solve()
{
    
    init();
    cin>>n>>m>>k;
    cout<<m*qmi((m-1),k,mod)%mod*c[n-1][k]%mod<<endl;
}
signed main()
{
    
    io;
    //cin>>_; 
    //while(_--)
    solve();
    return 0;
}

原网站

版权声明
本文为[leimingzeOuO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207171826062316.html