QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#615629 | #9442. Music Game | ucup-team3586# | WA | 27ms | 6192kb | C++14 | 820b | 2024-10-05 19:35:44 | 2024-10-05 19:35:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
#define ll long long
struct qq{
ll t,a,b;
bool operator < (const qq &e) const{
return e.b*(b*t+a*e.t)<b*(e.b*e.t+e.a*t);
}
}z[201000];
int n;
int qpow(int a,int b){
int c=1;
for(;b;b>>=1){
if(b&1)c=1ll*a*c%mod;
a=1ll*a*a%mod;
}
return c;
}
int main(){
scanf("%d",&n);
ll all=0;
for(int i=1;i<=n;i++)
scanf("%lld%lld%lld",&z[i].t,&z[i].a,&z[i].b);
sort(z+1,z+n+1);
ll p=1,su=0;
for(int i=1;i<=n;i++){
(su+=1ll*p*z[i].t%mod)%=mod;
p=1ll*p*z[i].a%mod*qpow(z[i].b,mod-2)%mod;
}
su=1ll*su*qpow(1-p,mod-2)%mod;
(all+=1ll*(qpow(p,mod-2)-1)*su%mod)%=mod;
(all+=mod)%=mod;
printf("%lld",all);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3912kb
input:
2 3 3 5 2 4 7
output:
831870305
result:
ok "831870305"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
5 2 5 9 6 4 7 1 9 14 17 8 13 10 4 11
output:
914017655
result:
ok "914017655"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
8 6 2 8 3 1 8 5 30 71 7 9 58 6 4 7 6 9 25 2 8 67 6 6 55
output:
923892723
result:
ok "923892723"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 2 2 3 1 5 6
output:
399297746
result:
ok "399297746"
Test #5:
score: 0
Accepted
time: 2ms
memory: 4000kb
input:
6057 598846 477861 477861 355457 471360 471360 52553 53505 53505 910434 715394 957062 829770 396343 396343 388604 220815 628584 697515 339144 976739 134698 713562 713562 103516 548592 976096 328488 131879 979654 360558 458803 458803 609012 481090 852195 207954 434215 434215 74492 313219 453266 11312...
output:
209793398
result:
ok "209793398"
Test #6:
score: 0
Accepted
time: 20ms
memory: 5220kb
input:
60325 249263 702771 806647 825858 894224 894224 954851 857512 857512 682622 271953 271953 37366 859065 859065 455311 280629 280629 139413 628817 628817 289777 745827 889101 941889 44512 44512 261500 956143 956143 683456 849819 849819 380838 640198 640198 458670 425331 923542 724423 786203 786203 886...
output:
401590376
result:
ok "401590376"
Test #7:
score: 0
Accepted
time: 27ms
memory: 6192kb
input:
92527 45889 267333 275737 192999 354289 476002 466286 564920 564920 462999 71086 71086 812092 291868 308621 691602 7181 658070 932827 698613 698613 421190 429765 957938 835947 301778 301778 37833 286079 519204 310540 190221 438559 373458 283897 832299 252879 196799 846520 579418 630867 630867 549650...
output:
96242233
result:
ok "96242233"
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3812kb
input:
1 1 1 1
output:
0
result:
wrong answer 1st words differ - expected: '1', found: '0'