| Task: | Lukujono |
| Sender: | Gomhog |
| Submission time: | 2025-11-28 22:05:12 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
Code
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int tcs;
cin>>tcs;
for (int tc=0;tc<tcs;tc++) {
int n;
cin>>n;
int cnt=1;
bool halt=true;
while (n>1) {
if (n%3==2) {
halt=false;
cout<<-1<<"\n";
break;
}
if (n%3==0) n/=3;
else n = 2*n + 1;
cnt++;
}
if (halt) cout<<cnt<<"\n";
}
}Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1000 1 2 3 4 ... |
| correct output |
|---|
| 1 -1 2 4 -1 ... |
| user output |
|---|
| 1 -1 2 4 -1 ... |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 1000 152435 165584 587562 428318 ... |
| correct output |
|---|
| -1 -1 -1 -1 -1 ... |
| user output |
|---|
| -1 -1 -1 -1 -1 ... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 1000 235119 235120 235144 236196 ... |
| correct output |
|---|
| 27 27 27 14 27 ... |
| user output |
|---|
| 27 27 27 14 27 ... |
