QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177231 | #5301. Modulo Ruins the Legend | ballance | WA | 6ms | 3748kb | C++23 | 1.8kb | 2023-09-12 18:23:41 | 2023-09-12 18:23:41 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <sstream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<array>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<unordered_map>
#include<random>
#include<bitset>
#include <functional>
//#include <bits/stdc++.h>
typedef long long ll;//unsigned
typedef long double ld;
#define pii pair<int,int>
#define pip pair<int,pii>
#define pb push_back
#define fi first
#define se second
#define lowbit(x) (x&-x)
#define f(x)(y) x+y
//#define int ll
using namespace std;
minstd_rand gen;
const ld PI = 3.14159265358979323846264338327950288419716939937510L;
const ld eps = 1e-10;
const int N = 100010, M = 20010;
ld a[N];
ll gcd(ll x, ll y)
{
if (x > y)
swap(x, y);
if (x == 0)return y;
return gcd(y % x, x);
}
ll moni(ll x, ll p)
{
if (x == 1)
return 1;
return ((1 - p * moni(p % x, x)) / x + p * p) % p;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n, m; cin >> n >> m;
ll sum = 0;
for (int i = 1; i <= n; i++)
{
int a; cin >> a;
sum += a;
}
ll x, y;
ll kk[2];
int GCD = gcd(n, m);
{
int k = sum % GCD;
kk[0] = k;
if (k == sum)
{
x = 0;
goto door;
}
int right = (k - sum + m) % m;
x = right / GCD * moni(n / GCD, m / GCD);
}
door:;
{
int k = (sum + n * (n + 1) / 2) % GCD;
kk[1] = k;
if (k == sum)
{
y = 0;
goto door1;
}
int right = (k - sum + m - n * (n + 1) / 2 % m + m) % m;
y = right / GCD * moni(n / GCD, m / GCD);
}
door1:;
if (kk[0] < kk[1])
cout << kk[0] << '\n' << x << ' ' << 0;
else
cout << kk[1] << '\n' << y << " " << 1 % m;
}
/*
6
0 0
1 -1
2 0
2 1
1 1
0 1
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3688kb
input:
6 24 1 1 4 5 1 4
output:
1 2 1
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
7 29 1 9 1 9 8 1 0
output:
0 25 1
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
1 1000000000 963837005
output:
0 36162994 1
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
2 1000000000 948507269 461613424
output:
0 294939652 1
result:
ok ok
Test #7:
score: 0
Accepted
time: 3ms
memory: 3624kb
input:
100000 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
0 0 0
result:
ok ok
Test #8:
score: -100
Wrong Answer
time: 6ms
memory: 3668kb
input:
100000 1000000000 253614966 278270960 980235895 498158918 928430170 216003119 852570558 948400590 239257296 897053667 294741176 38297441 382677590 406314557 609468973 854148232 314532767 738191551 158215002 5865825 920471826 380037058 356271728 749175327 28319049 208101105 953758995 896570758 521930...
output:
46613 -5360 1
result:
wrong answer Integer parameter [name=s] equals to -5360, violates the range [0, 999999999]