QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#673560#9376. GameLoxilanteWA 93ms3688kbC++141.6kb2024-10-24 23:54:082024-10-24 23:54:09

Judging History

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

  • [2024-10-24 23:54:09]
  • 评测
  • 测评结果:WA
  • 用时:93ms
  • 内存:3688kb
  • [2024-10-24 23:54:08]
  • 提交

answer

#define F_C
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#endif
const int MOD = 998244353;
int quickPow(int a, int b)
{
    int p = a, ans = 1;
    while(b)
    {
        if (b&1) ans *= p, ans %= MOD;
        p *= p; p %= MOD;
        b >>= 1;
    }
    return ans;
}
int inv(int a)
{
    return quickPow(a, MOD-2);
}
signed main(void)
{
    #ifdef LOCAL
//	freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
//	freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
    #endif
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int T = next();
    while(T--)
    {
        int x, y, a, b, p, ans = 0, now = 1;
        cin>>x>>y>>a>>b>>p;
        int p1 = a*inv(a+b), p2 = b*inv(a+b);

        while(x != y)
        {
            int t, pre = now;
            if (x > y)
            {
                t = (x-1)/y;
                x -= t*y;
                now *= quickPow(p2, t);
                now %= MOD;
                ans += pre-now;
            }
            else
            {
                t = (y-1)/x;
                y -= t*x;
                now *= quickPow(p1, t);
                now %= MOD;
            }
        }
        ans += now*p1;
        
        cout<<(ans%MOD+MOD)%MOD<<endl;
    }
    
    return 0;
}
/*

 */

詳細信息

Test #1:

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

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: -100
Wrong Answer
time: 93ms
memory: 3628kb

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:

57660923
349699982
612621163
715857038
592200562
76520153
870227707
169499045
667597353
415694940
140987510
464905228
426243016
864656779
750317399
268631494
486881524
16020688
198191519
189360084
966510181
512645443
695650039
709706254
550002158
616407070
458326158
551455286
667870434
918218440
593...

result:

wrong answer 1st lines differ - expected: '947058399', found: '57660923'