QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#709300 | #5301. Modulo Ruins the Legend | _Felix | WA | 25ms | 4232kb | C++14 | 2.2kb | 2024-11-04 13:51:54 | 2024-11-04 13:51:55 |
Judging History
answer
// #define LawrenceSivan
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using d64 = long double;
#define INF 0x3f3f3f3f
// #define int i64
constexpr int maxn = 1e5 + 5;
constexpr int base = 131;
constexpr int mod = 1e9 + 7;
constexpr double eps = 1e-8;
namespace IO {
template<typename T>
inline void read(T &x) {
x = 0;
T f = 1;
char ch = getchar();
while (!isdigit(ch)) {if (ch == '-')f = -1; ch = getchar();}
while (isdigit(ch)) {x = x * 10 + (ch ^ 48); ch = getchar();}
x *= f;
}
template <typename T, typename... Args>
inline void read(T &t, Args &... args) {
read(t);
read(args...);
}
template<typename T>
void write(T x) {
if (x < 0)putchar('-'), x = -x;
if (x > 9)write(x / 10);
putchar(x % 10 + '0');
}
template<typename T, typename... Args>
void write(T t, Args... args) {
write(t);
putchar(' ');
write(args...);
}
}
using namespace IO;
const int N = 1e5 + 10;
typedef long long ll;
int n, m, a[N];
ll exgcd(ll a, ll b, ll &x, ll &y) {
if(b == 0) {
x = 1; y = 0;
return a;
}
ll t = exgcd(b, a % b, y, x);
y -= a / b * x;
return t;
}
void work(ll a, ll b, ll c, ll &qqq, ll &ppp) {
ll x, y;
ll g = exgcd(a, b, x, y);
x *= (c / g); y *= (c / g);
qqq = x; ppp = y;
return;
}
inline void solve() {
int sum = 0;
cin>>n>>m;
for(int i = 1; i <= n; i++)
cin>>a[i], sum = (sum + a[i]) % m;
int g = __gcd((ll)n, (ll)n * (n + 1) / 2);
int t = __gcd(g, m);
int ze = (m - sum + t - 1) / t;
int ans = (sum + (ll)ze * t % m) % m;
printf("%d\n", ans);
//cout<<(ans + m - sum) % m<<endl;
ll s, d, k, tt;
work(g, m, ans - sum, k, tt);
work(n, (ll)n * (n + 1) / 2, (ll)k * g, s, d);
printf("%lld %lld\n", (s % m + m) % m, (d % m + m) % m);
return;
}
signed main() {
#ifdef LawrenceSivan
// freopen("a.in", "r", stdin);
freopen("a.txt", "w", stdout);
#endif
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
input:
6 24 1 1 4 5 1 4
output:
1 15 19
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
7 29 1 9 1 9 8 1 0
output:
0 0 0
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
1 1000000000 963837005
output:
0 0 36162995
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 1000000000 948507269 461613424
output:
0 410120693 589879307
result:
ok ok
Test #7:
score: 0
Accepted
time: 9ms
memory: 4152kb
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: 0
Accepted
time: 21ms
memory: 4224kb
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 535950000 999989281
result:
ok ok
Test #9:
score: -100
Wrong Answer
time: 25ms
memory: 4232kb
input:
100000 998244353 561002596 498658036 721339539 63377827 532179242 934651519 234198881 490149304 2056307 499913682 427679408 694677560 516580968 300129454 816286800 688594301 183049581 456627420 495848352 273497462 953217060 796225499 207179832 728054671 409492082 25003432 810431468 206421553 5569626...
output:
0 331080376 966134193
result:
wrong answer Result not equal to solution.