QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#41310 | #4384. Walk | 01shijian# | WA | 26ms | 3576kb | C++17 | 2.1kb | 2022-07-29 14:52:29 | 2022-07-29 14:52:30 |
Judging History
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 P = 1e9 + 7;
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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 26ms
memory: 3576kb
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:
499671423 933218829 838686385 884408926 484562284 776600711 998490738 966880920 973956869 181099551 242548582 433831677 461355327 817278247 86342520 992019258 16101726 822272311 273214110 953688954 419384752 129250548 835066241 135403109 42849115 114444897 956066378 661599599 315417062 309774808 882...
result:
wrong answer 1st lines differ - expected: '748098408', found: '499671423'