社区讨论
样例没过,但AC
P13696 「CyOI」出包魔法师参与者 5已保存回复 8
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 8 条
- 当前快照
- 1 份
- 快照标识符
- @mhjhjvzv
- 此快照首次捕获于
- 2025/11/04 02:40 4 个月前
- 此快照最后确认于
- 2025/11/04 02:40 4 个月前
是数据水了吗
CPP#define LOCAL
#include<bits/stdc++.h>
#include<unistd.h>
#include<bits/extc++.h>
//#define getchar my_gechar
#define ll long long
#define int __int128
#define db double
#define ldb long double
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define vec Point
#define fill0(a) memset(a,0,sizeof(a))
#define fill1(a) memset(a,-1,sizeof(a))
#define fillbig(a) memset(a,63,sizeof(a))
// #define max(a,b) ((a)<(b)?(b):(a))
// #define min(a,b) ((a)<(b)?(a):(b))
#define vi vector<int>
#define vl vector<ll>
#define lowbit(x) (x)&(-x)
//#define sort stable_sort
using namespace std;
using namespace __gnu_pbds;
char buffer[32769];
unsigned li = 0;
inline char my_gechar(){
if(buffer[li] == '\0') buffer[read(0, buffer, 32768)] = '\0',li = 0;
return buffer[li++];
}
namespace ly
{
namespace IO
{
#ifndef LOCAL
constexpr auto maxn=1<<20;
char in[maxn],out[maxn],*p1=in,*p2=in,*p3=out;
#define flush() (fwrite(out,1,p3-out,stdout))
#define putchar(x) (p3==out+maxn&&(flush(),p3=out),*p3++=(x))
class Flush{public:~Flush(){flush();}}_;
#endif
namespace usr
{
template<typename type>
inline type read(type &x)
{
x=0;bool flag(0);char ch=getchar();
while(!isdigit(ch)) flag^=ch=='-',ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return flag?x=-x:x;
}
template<typename type>
inline void write(type x)
{
x<0?x=-x,putchar('-'):0;
static short Stack[50],top(0);
do Stack[++top]=x%10,x/=10;while(x);
while(top) putchar(Stack[top--]|48);
}
inline int read(double &x){return scanf("%lf",&x);}
inline int read(long double &x){return scanf("%Lf",&x);}
inline void dwrite(const double &x,int y=6,bool flag=1){printf("%.*lf",y,x),flag?putchar(' '):putchar(' ');}
inline void dwrite(const long double &x,int y=6,bool flag=1){printf("%.*Lf",y,x),flag?putchar(' '):putchar(' ');}
inline char read(char &x){do x=getchar();while(isspace(x));return x;}
inline char write(const char &x){return putchar(x);}
inline void read(char *x){static char ch;read(ch);do *(x++)=ch;while(!isspace(ch=getchar())&&~ch);}
inline void write(const char *x){while(*x)putchar(*(x++));}
inline void read(string &x){char ch[1000005]={};read(ch),x=ch;}
inline void write(const string &x){int len=x.length();for(int i=0;i<len;++i)putchar(x[i]);}
template<typename type,typename...T>
inline void read(type &x,T&...y){read(x),read(y...);}
template<typename type,typename...T>
inline void write(const type &x,const T&...y){write(x),putchar(' '),write(y...),sizeof...(y)^1?0:putchar(' ');}
inline __int128 read(){static __int128 x;return read(x);}
template<typename type>
inline type put(type x,bool flag=1){write(x),flag?putchar(' '):putchar(' ');return x;}
}
#ifndef LOCAL
#undef getchar
#undef flush
#undef putchar
#endif
}using namespace IO::usr;
}using namespace ly::IO::usr;
struct Point{
int x,y;
Point operator +(const Point& b)const{return {x+b.x,y+b.y};}
Point operator -(const Point& b)const{return {x-b.x,y-b.y};}
bool operator <(const Point& b)const{
if(x!=b.x)return x<b.x;
return y<b.y;
}
};
const int N=1e7+5;
const int M=1e6+5;
const int inf=1e9+5;
const int mod=998244353;
const int bit=50;
//mt19937 sj(chrono::steady_clock::now().time_since_epoch().count());
int B=705;
int n,m,k;
int l[M];
int f[M];
inline int qpow(int a,int b){
int res=1;
while(b){
if(b&1) res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
ll fac[N],inv[N];
inline void init(){
fac[0]=1;
for(int i=1;i<N;++i) fac[i]=fac[i-1]*i%mod;
inv[N-1]=qpow(fac[N-1],mod-2);
for(int i=N-2;i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod;
}
inline int C(int n,int m){
return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
struct node{
db val;
int pos;
}a[M];
inline bool cmp(node a,node b){
return a.val>b.val;
}
inline void solve(){
read(m,k);
for(int i=1;i<=m;++i){
read(l[i]);
n+=l[i];
}
int sum=0;
for(int i=1;i<=m;++i){
f[i]=l[i]*k/n;
sum+=f[i];
a[i]={(db)(l[i]-f[i])/(1.0*(f[i]+1)),i};
}
sort(a+1,a+m+1,cmp);
for(int i=1;i<=k-sum;++i){
int x=a[i].pos;
f[x]++;
}
int ans=1;
for(int i=1;i<=m;++i){
///cout<<l[i]<<' '<<f[i]<<endl;
ans=ans*C(l[i],f[i])%mod;
}
write(ans);
}
signed main()
{
int _=1;
init();
while(_--) solve();
return (0-0);
}
回复
共 8 条回复,欢迎继续交流。
正在加载回复...