| Task: | Finding inverse |
| Sender: | aalto26kh_016 |
| Submission time: | 2026-11-16 15:28:04 +0200 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | WRONG ANSWER | 0.00 s | details |
| #4 | WRONG ANSWER | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | WRONG ANSWER | 0.00 s | details |
| #7 | WRONG ANSWER | 0.00 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | WRONG ANSWER | 0.00 s | details |
| #10 | WRONG ANSWER | 0.01 s | details |
| #11 | WRONG ANSWER | 0.00 s | details |
| #12 | WRONG ANSWER | 0.61 s | details |
| #13 | WRONG ANSWER | 0.30 s | details |
| #14 | ACCEPTED | 0.96 s | details |
Compiler report
input/code.cpp: In member function 'bool compute::start()':
input/code.cpp:35:18: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
35 | if (b==1|b2==1) break;
| ~^~~Code
#include <iostream>
#include <vector>
#include <climits>
#include <cstdint>
using namespace std;
#define DEBUG std::cout<<"LINE"<<__LINE__;
#define IN(A) uint64_t A;std::cin>>A;
template<typename T> void printV(vector<T> V) {
for (int i=0;i<V.size()-1;i++) {
cout<<V[i]<<" ";
}
cout<<V[V.size()-1];
cout<<endl;
}
int64_t max3(int64_t a,int64_t b,int64_t c) {
return max(a,max(b,c));
}
struct compute {
int tests=1;
vector<int> data;
vector<pair<int,int>> result;
vector<bool> visited;
bool start() {
IN(a);
IN(M);
uint64_t b=a;
uint64_t i=1;
uint64_t b2=a*2%M;
for (;i<M;i+=2) {
if (b==1|b2==1) break;
b=(b2+a);
b2=(b2+2+a);
if (b>M) b=b-M;
if (b2>M) b2=b2-M;
}
if (b==1) {
cout<<i*2-1<< endl;
} else {
if (b2==1) {
cout<<i*2<<endl;
}
else cout<<-1<<endl;
}
return true;
}
void readV(int n) {
for (int i=0;i<n;i++) cin>>data[i];
}
void testloop(){
while (tests-->0) {
start();
}
}
};
int main() {
ios_base::sync_with_stdio(false);
// cin.tie(NULL);
compute comp;
comp.start();
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 6 7 |
| correct output |
|---|
| 6 |
| user output |
|---|
| -1 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 0 7 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 5 78 |
| correct output |
|---|
| 47 |
| user output |
|---|
| 86 |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 89 99 |
| correct output |
|---|
| 89 |
| user output |
|---|
| -1 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 0 61 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 897 947 |
| correct output |
|---|
| 625 |
| user output |
|---|
| 546 |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 419 538 |
| correct output |
|---|
| 217 |
| user output |
|---|
| -1 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 32 938 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 184120 505187 |
| correct output |
|---|
| 438779 |
| user output |
|---|
| 251157 |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 264601 885661 |
| correct output |
|---|
| 360221 |
| user output |
|---|
| -1 |
Test 11
Verdict: WRONG ANSWER
| input |
|---|
| 40310 590135 |
| correct output |
|---|
| -1 |
| user output |
|---|
| 514297 |
Test 12
Verdict: WRONG ANSWER
| input |
|---|
| 202254499 577081420 |
| correct output |
|---|
| 128866679 |
| user output |
|---|
| 965211134 |
Test 13
Verdict: WRONG ANSWER
| input |
|---|
| 539836073 888851205 |
| correct output |
|---|
| 797044652 |
| user output |
|---|
| 470250446 |
Test 14
Verdict: ACCEPTED
| input |
|---|
| 697847215 756971670 |
| correct output |
|---|
| -1 |
| user output |
|---|
| -1 |
