QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#41309#4384. Walk01shijian#WA 27ms3584kbC++172.1kb2022-07-29 14:50:432022-07-29 14:50:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-29 14:50:44]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:3584kb
  • [2022-07-29 14:50:43]
  • 提交

answer

/*
* @Author: ISSAC
* @Date:   2022-07-29
* @File:   K.cpp
* @Last Modified time: 2022-07-29
*/
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
typedef long long i64;
typedef pair<int,int> PII;
mt19937 rnd();
const int mod = 1e9 + 7;

const int P = 998244353;
int norm(int x) {
    if (x < 0) {
        x += P;
    }
    if (x >= P) {
        x -= P;
    }
    return x;
}
template<class T>
T power(T a, i64 b) {
    T res = 1;
    for (; b; b /= 2, a *= a) {
        if (b % 2) res *= a;
    }
    return res;
}

struct Z {
    int x;
    Z(int x = 0) : x(norm(x)) {}
    Z(i64 x) : x(norm(x % P)) {}
    int val() const {
        return x;
    }
    Z operator-() const {
        return Z(norm(P - x));
    }
    Z inv() const {
        assert(x != 0);
        return power(*this, P - 2);
    }
    Z &operator*=(const Z &rhs) {
        x = i64(x) * rhs.x % P;
        return *this;
    }
    Z &operator+=(const Z &rhs) {
        x = norm(x + rhs.x);
        return *this;
    }
    Z &operator-=(const Z &rhs) {
        x = norm(x - rhs.x);
        return *this;
    }
    Z &operator/=(const Z &rhs) {
        return *this *= rhs.inv();
    }
    friend Z operator*(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res *= rhs;
        return res;
    }
    friend Z operator+(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res += rhs;
        return res;
    }
    friend Z operator-(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res -= rhs;
        return res;
    }
    friend Z operator/(const Z &lhs, const Z &rhs) {
        Z res = lhs;
        res /= rhs;
        return res;
    }
    friend std::istream &operator>>(std::istream &is, Z &a) {
        i64 v;
        is >> v;
        a = Z(v);
        return is;
    }
};

void solve(){
	int n, m; cin >> n >> m;
	Z a = Z(n - m) / Z(2);
	cout << a.val() << "\n";
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); 
    int _; cin >> _;
    while(_ --){
    	solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 27ms
memory: 3584kb

input:

99990 99987
757148 167851001 301413357 336971125 659598369 160567226 391749388 4890852 35766291 26239573 473038165 597007 3615545 326051437 392289611 118341523 170427799 37215529 675016434 168544291 683447134 950090227 82426873 116752252 194041605 706221269 71664782 257655784 84970744 21417563 37379...

output:

498793596
931463175
836930731
882653272
483684457
774845057
996735084
965125266
972201215
180221724
241670755
433831677
460477500
816400420
86342520
990263604
16101726
820516657
273214110
951933300
418506925
129250548
833310587
135403109
42849115
114444897
954310724
659843945
314539235
308896981
880...

result:

wrong answer 1st lines differ - expected: '748098408', found: '498793596'