QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140276#4556. 你的生命已如风中残烛myee100 ✓8ms1768kbC++115.8kb2023-08-15 16:49:382023-08-15 16:49:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-15 16:49:40]
  • 评测
  • 测评结果:100
  • 用时:8ms
  • 内存:1768kb
  • [2023-08-15 16:49:38]
  • 提交

answer

// u1s1 这个 Raney 引理一但想到就简单了。
// 每一项减 1,显然逐项和变为了 0,而且要求任何前缀和都 >= 0。
// 直接照搬 Raney 引理肯定是不行的。因为你无法构造合法的双射。开头补 1 无法回推。
// 考虑重新做一次证明。
// 我们把几何折线画出来,显然仅可从最低点出发。
// 问题是最低点有几个。
// ...
// 咱也没得做是吧。
// 还是考虑 Raney 引理。
// 咋整呢?
// 考虑把每个正数拆成若干个 1,开头补 1,然后只用暴力枚举某个数被拆开放到头尾的情况?
// 似乎也不行……
// 怎么办?
// 开头加 1 不行
// 末尾补一个 -1
// 然后就是后缀恒负
// 取反并翻转后就和 Raney 引理一样了。
// 于是即为 (m+1)!/(m+1)(m-n+1)=m!/(m-n+1) (最后这个相除是考虑 -1 的标号)

#include <algorithm>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
    T ans=1%mod;
    while(index)
    {
        if(index&1)ans=ans*base%mod;
        base=base*base%mod,index>>=1;
    }
    return ans;
}
namespace ConstMod
{
    template<const ullt p>
    class mod_ullt
    {
        private:
            ullt v;
            inline ullt chg(ullt w){return(w<p)?w:w-p;}
            inline mod_ullt _chg(ullt w){mod_ullt ans;ans.v=(w<p)?w:w-p;return ans;}
        public:
            mod_ullt():v(0){}
            mod_ullt(ullt v):v(v%p){}
            bol empty(){return!v;}
            inline ullt val(){return v;}
            friend bol operator<(mod_ullt a,mod_ullt b){return a.v<b.v;}
            friend bol operator>(mod_ullt a,mod_ullt b){return a.v>b.v;}
            friend bol operator<=(mod_ullt a,mod_ullt b){return a.v<=b.v;}
            friend bol operator>=(mod_ullt a,mod_ullt b){return a.v>=b.v;}
            friend bol operator==(mod_ullt a,mod_ullt b){return a.v==b.v;}
            friend bol operator!=(mod_ullt a,mod_ullt b){return a.v!=b.v;}
            inline friend mod_ullt operator+(mod_ullt a,mod_ullt b){return a._chg(a.v+b.v);}
            inline friend mod_ullt operator-(mod_ullt a,mod_ullt b){return a._chg(a.v+a.chg(p-b.v));}
            inline friend mod_ullt operator*(mod_ullt a,mod_ullt b){return a.v*b.v;}
            friend mod_ullt operator/(mod_ullt a,mod_ullt b){return b._power(p-2)*a.v;}
            friend mod_ullt operator^(mod_ullt a,ullt b){return a._power(b);}
            inline mod_ullt operator-(){return _chg(p-v);}
            mod_ullt sqrt()
            {
                if(power(v,(p-1)>>1,p)!=1)return 0;
                mod_ullt b=1;do b++;while(b._power((p-1)>>1)==1);
                ullt t=p-1,s=0,k=1;while(!(t&1))s++,t>>=1;
                mod_ullt x=_power((t+1)>>1),e=_power(t);
                while(k<s)
                {
                    if(e._power(1llu<<(s-k-1))!=1)x*=b._power((1llu<<(k-1))*t);
                    e=_power(p-2)*x*x,k++;
                }
                return _min(x,-x),x;
            }
            mod_ullt inv(){return _power(p-2);}
            mod_ullt _power(ullt index){mod_ullt ans(1),w(v);while(index){if(index&1)ans*=w;w*=w,index>>=1;}return ans;}
            voi read(){v=0;chr c;do c=getchar();while(c>'9'||c<'0');do v=(c-'0'+v*10)%p,c=getchar();while(c>='0'&&c<='9');v%=p;}
            voi print()
            {
                static chr C[20];uint tp=0;
                ullt w=v;do C[tp++]=w%10+'0',w/=10;while(w);
                while(tp--)putchar(C[tp]);
            }
            voi println(){print(),putchar('\n');}
            mod_ullt operator++(int){mod_ullt ans=*this;return v=chg(v+1),ans;}
        public:
            inline ullt&operator()(){return v;}
            inline mod_ullt&operator+=(mod_ullt b){return*this=_chg(v+b.v);}
            inline mod_ullt&operator-=(mod_ullt b){return*this=_chg(v+chg(p-b.v));}
            inline mod_ullt&operator*=(mod_ullt b){return*this=v*b.v;}
            mod_ullt&operator^=(ullt b){return*this=_power(b);}
            mod_ullt&operator/=(mod_ullt b){return*this=b._power(p-2)*v;}
            mod_ullt&operator++(){return v=chg(v+1),*this;}
    };
}
const ullt Mod=998244353;
typedef ConstMod::mod_ullt<Mod>modint;
int main()
{
#ifdef MYEE
    freopen("QAQ.in","r",stdin);
#endif
    modint ans(1);
    uint n,m=0;scanf("%u",&n);
    for(uint i=0,v;i<n;i++)scanf("%u",&v),m+=v;
    for(uint i=1;i<=m;i++)ans*=i;
    ans/=m-n+1;
    ans.println();
    return 0;
}

// Never Gonna Give You Up
// 明天你是否会想起 昨天未调完的题 明天你是否还惦记 考场写挂的暴力
// 集训队都已想不起 没能来雅礼的你 我也是偶然翻 OJ 才想起退役的你
// 谁羡慕比赛 AK 的你 谁膜拜红名的你 谁看了你的生涯回忆 谁借走你的 RP
// 你从前总是很小心 对拍后才肯交题 你也曾无意中说起 喜欢在深夜 AC
// 那时候比赛总很难 rating 总长得太慢 你总说退役遥遥无期 转眼就各分东西
// 谁秒了你出的模拟题 谁骂着毒瘤的你 谁看了你的题解笔记 谁传给学妹学弟
// 同行的日子都远去 我们也终会退役 多年后谁会再想起 定格考场的记忆
// 谁记得你出的模拟题 谁忘记毒瘤的你 谁学会你的题解笔记 谁教给学妹学弟

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 0ms
memory: 1484kb

input:

3
3 4 3

output:

453600

result:

ok 1 number(s): "453600"

Test #2:

score: 5
Accepted
time: 0ms
memory: 1508kb

input:

4
1 2 2 5

output:

518400

result:

ok 1 number(s): "518400"

Test #3:

score: 5
Accepted
time: 2ms
memory: 1540kb

input:

8
76668 53399 70796 78419 57556 68926 1915 38643

output:

949898459

result:

ok 1 number(s): "949898459"

Test #4:

score: 5
Accepted
time: 2ms
memory: 1760kb

input:

8
66474 53912 38061 43182 61784 95147 58210 25497

output:

595228635

result:

ok 1 number(s): "595228635"

Test #5:

score: 5
Accepted
time: 2ms
memory: 1484kb

input:

8
98193 97463 63155 19717 46275 13410 75877 75493

output:

77039665

result:

ok 1 number(s): "77039665"

Test #6:

score: 5
Accepted
time: 2ms
memory: 1760kb

input:

8
88099 65208 63288 61281 50503 39730 22505 85448

output:

734593689

result:

ok 1 number(s): "734593689"

Test #7:

score: 5
Accepted
time: 4ms
memory: 1544kb

input:

15
88953 89816 89181 67185 22983 51194 99579 66504 1866 61943 65666 98681 26437 60568 92391

output:

495839407

result:

ok 1 number(s): "495839407"

Test #8:

score: 5
Accepted
time: 1ms
memory: 1516kb

input:

15
479 79765 44320 376 82158 92270 2228 93620 6831 22806 74653 79140 2304 53934 96027

output:

180050111

result:

ok 1 number(s): "180050111"

Test #9:

score: 5
Accepted
time: 2ms
memory: 1504kb

input:

15
12004 69814 9127 89635 64634 33247 27978 43937 34996 50900 60441 26730 1372 24201 32332

output:

442907238

result:

ok 1 number(s): "442907238"

Test #10:

score: 5
Accepted
time: 6ms
memory: 1540kb

input:

30
9465 65528 44324 20323 74038 30853 532 99742 30429 45037 61788 84513 73278 57936 90669 67403 86753 32015 82990 69216 99199 51188 14918 74830 37131 19915 41077 95485 71170 23935

output:

201701591

result:

ok 1 number(s): "201701591"

Test #11:

score: 5
Accepted
time: 6ms
memory: 1488kb

input:

30
20991 55477 76263 76814 33214 71829 70413 50058 58594 96331 47575 32203 39577 28202 94305 54046 10126 97985 50447 4156 69694 75439 24073 74534 45307 26576 52247 59925 16133 97093

output:

722280885

result:

ok 1 number(s): "722280885"

Test #12:

score: 5
Accepted
time: 3ms
memory: 1744kb

input:

15
15087 9880 81660 61274 51644 47011 35666 53433 28306 86973 44311 78046 21037 57611 67488

output:

884473359

result:

ok 1 number(s): "884473359"

Test #13:

score: 5
Accepted
time: 6ms
memory: 1520kb

input:

30
14768 64470 96472 95312 81873 67839 59299 85410 36170 66860 31286 34221 41954 59651 65415 51788 17057 2767 72705 40337 63741 26430 39686 36819 68540 67239 40647 49301 3104 2520

output:

107610869

result:

ok 1 number(s): "107610869"

Test #14:

score: 5
Accepted
time: 6ms
memory: 1700kb

input:

30
15245 76824 93084 43530 72897 23572 64270 75889 40810 21098 92761 73297 69662 15210 58934 49962 21610 40994 64913 31550 32971 60902 24393 11055 19414 60659 94266 47631 96433 41597

output:

690905035

result:

ok 1 number(s): "690905035"

Test #15:

score: 5
Accepted
time: 7ms
memory: 1504kb

input:

40
8611 64120 18331 37619 1558 19389 23458 85917 34582 69329 71506 52661 64261 79485 24463 71055 91279 32361 65807 9990 16707 58942 68602 26458 35383 86675 33840 22025 18976 25049 65190 92830 75996 56038 10741 38048 94346 21241 81095 42594

output:

657182250

result:

ok 1 number(s): "657182250"

Test #16:

score: 5
Accepted
time: 8ms
memory: 1768kb

input:

40
97085 74070 53624 81128 42383 78313 97709 35701 6417 8466 62518 72303 65194 86119 20826 28544 67906 99259 54318 51849 46212 34791 59447 26654 94439 47247 22669 80785 6782 61458 19527 8271 69923 31258 73669 75318 95475 56110 48960 82049

output:

330077666

result:

ok 1 number(s): "330077666"

Test #17:

score: 5
Accepted
time: 7ms
memory: 1424kb

input:

40
95334 47767 36263 40312 86008 31844 39297 30508 46362 2439 53605 24682 82254 9918 45396 10196 54678 35276 74629 26497 45520 11872 6808 66135 3413 26648 99060 60661 86918 19950 25089 59502 48414 89418 78723 64352 97194 9522 54778 5069

output:

473192665

result:

ok 1 number(s): "473192665"

Test #18:

score: 5
Accepted
time: 7ms
memory: 1752kb

input:

40
96289 49175 39056 90248 58387 10641 16371 44332 32641 10915 43887 89302 14471 65268 78834 6544 73353 90998 24580 85723 51212 4117 8991 37707 49293 59788 6197 1354 15912 51604 98218 97840 36355 82607 12079 41266 73585 18870 69363 6738

output:

906838232

result:

ok 1 number(s): "906838232"

Test #19:

score: 5
Accepted
time: 5ms
memory: 1760kb

input:

40
18863 40119 62289 87780 62615 36861 72666 21619 61031 36066 9955 68607 52029 29111 25355 37624 15544 95776 22582 10791 22972 50716 86726 83810 70539 56589 65451 31904 70173 16508 62347 9339 95061 68342 36926 49487 39149 94510 8024 37894

output:

74083642

result:

ok 1 number(s): "74083642"

Test #20:

score: 5
Accepted
time: 8ms
memory: 1524kb

input:

40
30388 30069 94328 21071 21891 77937 65648 48735 56428 64061 95743 92997 51096 99278 28992 24167 6149 52078 90039 45731 93466 30835 72782 60314 1916 96017 76621 73144 38235 89567 8010 17098 68365 93122 18130 21886 38020 59642 72926 21638

output:

670711472

result:

ok 1 number(s): "670711472"

Extra Test:

score: 0
Extra Test Passed