QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#700416 | #5301. Modulo Ruins the Legend | tsogsummit# | TL | 101ms | 3668kb | C++23 | 1.6kb | 2024-11-02 12:56:56 | 2024-11-02 12:57:01 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
ll phi(ll n) {
ll result = n;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
while (n % i == 0)
n /= i;
result -= result / i;
}
}
if (n > 1)
result -= result / n;
return result;
}
using namespace std;
ll gcd(ll a, ll b) {
if(b == 0)
return a;
return gcd(b, a % b);
}
ll binpow(ll a, ll b , ll mod) {
ll res = 1;
a %= mod;
while(b > 0) {
if(b & 1){
res = res * a;
res %= mod;
}
a = a * a;
a %= mod;
b >>= 1;
}
return res % mod;
}
int main(){
long long n , m , i;
cin >> n >> m;
long long sum = 0 , a;
for(i = 0 ; i < n ; i ++){
cin >> a;
sum += a;
}
long long k = gcd(gcd(n , n*(n + 1)/ 2) , m);
long long res = sum % k;
cout << res << '\n';//hariu;
long long resres;
if(gcd(n *(n + 1) / 2, m) == k) {
cout << "0 ";
for(i = 0 ; i < m ; i++){
if((i * n*(n + 1)/ 2 + sum) % m == res){
cout << i;
return 0;
}
}
}
else{
for(i = 0 ; i < m ; i++){
if((i * n + sum) % m == res){
cout << i;
break;
}
}
cout << " 0";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
6 24 1 1 4 5 1 4
output:
1 0 5
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3656kb
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: 3580kb
input:
1 1 0
output:
0 0 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 101ms
memory: 3668kb
input:
1 1000000000 963837005
output:
0 0 36162995
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2 1 0 0
output:
0 0 0
result:
ok ok
Test #6:
score: -100
Time Limit Exceeded
input:
2 1000000000 948507269 461613424