QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#583223#9376. Gameucup-team3712WA 48ms3632kbC++201.8kb2024-09-22 19:04:282024-09-22 19:04:29

Judging History

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

  • [2024-09-22 19:04:29]
  • 评测
  • 测评结果:WA
  • 用时:48ms
  • 内存:3632kb
  • [2024-09-22 19:04:28]
  • 提交

answer

//在决定放弃以前多写一点题吧~
//just solve more problems before giving up

//created: 2024-09-22 18:44:32
//#define SKADI
#if defined(YUANSHEN)
#include<D:/Tovi/template/my_template.hpp>
#else
#include<bits/stdc++.h>
using namespace std;
#endif
#ifndef SKADI
#define dbg(...) 42
#endif
template <typename T1, typename T2> void cmin(T1 &x, const T2 &y) {
x = x < y ? x : y;
}
template <typename T1, typename T2> void cmax(T1 &x, const T2 &y) {
x = x > y ? x : y;
}
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define fixset(x) fixed<<setprecision(x)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define ALL(x) (x).begin()+1,(x).end()
#define see "\n*********C-O-D-E-F-O-R-C-E-S**********\n"
const int INF = 1000000000;
const ll LNF = 1000000000000000000;
const int mod = 998244353;
ll ksm(ll a,ll b)
{
    ll res=1;
    while(b){
        if(b&1) res=res*a%mod;
        a=a*a%mod,b>>=1;
    }
    return res;
}
ll inv(ll x){return ksm(x,mod-2);}
ll p0,p1;
ll dfs(int x,int y,int a,int b)
{
    if(x<=0) return 0;
    if(x==y){
        return p0;
    }
    if(x<y){
        //看看赢几局
        int n=y/x;
        if(y%x==0) n--;
        return ksm(p0,n)*dfs(x,y-n*x,a,b)%mod;
    }else{
        int n=x/y;
        if(x%y==0) n--;
        return ((1-ksm(p1,n+1)+mod)%mod+ksm(p1,n+1)*dfs(x-(n+1)*y,y,a,b))%mod;
    }
}
void solve()
{
    int x,y,a0,a1,b;
    cin>>x>>y>>a0>>a1>>b;
    p0=a0*inv(a0+a1)%mod,p1=a1*inv(a0+a1)%mod;
    // cerr<<p0<<'\n';
    cout<<dfs(x,y,0,0)<<'\n';
}

int main()
{
#ifndef SKADI
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    int T=1;
    cin>>T;
    while(T--)
        solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

input:

3
1 1
2 2 6
1 3
2 3 6
3 4
7 3 15

output:

499122177
910398850
220911476

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 47ms
memory: 3576kb

input:

100000
1 1000000000
12980050 128257807 266126484
1 1000000000
400255084 123438563 768881284
1000000000 1000000000
24563487 72082135 450057094
1 1000000000
56952077 40876000 193815114
1000000000 1000000000
82048274 239365585 326520865
1000000000 1
309821265 346013425 963168258
1 1
104158269 199365020...

output:

947058399
376449942
612621163
138416357
592200562
45779380
870227707
169499045
86396463
415694940
46851356
951368934
426243016
864656779
750317399
922456360
486881524
824329239
198191519
189360084
966510181
512645443
695650039
703100783
550002158
438470182
246877045
39876086
667870434
405196653
5935...

result:

ok 100000 lines

Test #3:

score: -100
Wrong Answer
time: 48ms
memory: 3628kb

input:

100000
167959139 481199252
18199423 25950409 149762920
773386884 579721198
16629525 28339910 152155823
2087506 268792718
43528658 6471925 90197530
691952768 717268783
516613092 94328992 743662288
45277106 856168102
309821265 346013425 963168258
279198849 527268921
30167950 166388455 577970339
140515...

output:

49955180
976140587
596147425
230388145
97624379
64774301
75375414
93163415
210461266
687531277
92044973
840420986
134705558
441011296
364978245
339210323
741165341
839204991
555939353
253380221
342820229
26852086
790567388
500817009
166788338
337783624
45460640
30290166
417670207
281681755
357256364...

result:

wrong answer 1st lines differ - expected: '623291477', found: '49955180'