QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#431434 | #6854. Umamusume | ucup-team3591# | WA | 1ms | 1276kb | C++14 | 1.1kb | 2024-06-05 15:40:33 | 2024-06-05 15:40:33 |
Judging History
answer
#include<cstdio>
typedef long long ll;
inline ll read(){
ll x=0;
int f=0,ch=0;
while(ch<48||ch>57) f=(ch=='-'),ch=getchar();
while(ch>47&&ch<58) x=(x<<3)+(x<<1)+(ch&15),ch=getchar();
return f?-x:x;
}
inline void write(ll x,char end='\n'){
if(x==0){
putchar('0');
putchar(end);
return;
}
if(x<0) putchar('-'),x=-x;
int ch[40]={0},cnt=0;
while(x){
ch[cnt++]=(int)(x%10);
x/=10;
}
while(cnt--) putchar(ch[cnt]+48);
putchar(end);
}
const ll mod=1e9+7;
ll n;
ll p;
inline ll fp(ll x,ll y){
ll s=1;
x=(x%mod+mod)%mod;
while(y){
if(y&1) s=s*x%mod;
x=x*x%mod;
y>>=1;
}
return s;
}
int main(){
int T=read();
while(T--){
n=read(),p=read();
if(n==0){
write(0);
continue;
}
if(n%2==0){
write(15ll*(n/2+1));
continue;
}
ll ans=15ll*(n/2+1);
ll r=n/6;
if(r>0){
ll p1=1-fp(1-p,r);
ll p2=1-fp(1-p,r)-fp(1-p,r-1)*p%mod*r%mod;
ll s=1-(1-p1)*(1-p2)%mod;
s=(s%mod+mod)%mod;
ans+=s*(7*p1+6*(1-p1)*p2%mod+3*(1-p1)*(p1-p2)%mod)%mod;
}
ans=(ans%mod+mod)%mod;
write(ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 1276kb
input:
10000 0 105131995 1 117692 2 637385120 3 836440520 4 658724304 5 514051456 6 5451264 7 96052631 8 71936851 9 105586941 10 707337536 11 671801275 12 918938970 13 771170452 14 426363392 15 134193130 16 836236496 17 255916160 18 308620046 19 368680120 20 509918554 21 302946768 22 604853125 23 686238240...
output:
0 15 30 30 45 45 60 966860739 75 5485168 90 498799792 105 261269185 120 590717461 135 357724464 150 794226760 165 889940952 180 841259094 195 233653444 210 689164033 225 360831810 240 627716590 255 192741039 270 728030178 285 797951899 300 703150862 315 377396600 330 484194922 345 119266858 360 5188...
result:
wrong answer 103rd lines differ - expected: '914769260', found: '5914769295'