| Task: | Lukujono |
| Sender: | ollpu |
| Submission time: | 2025-11-28 23:03:41 +0200 |
| Language: | C++ (C++20) |
| 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>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
for (int ti = 0; ti < t; ++ti) {
long x;
cin >> x;
int steps = 0;
while (x != 1) {
if (x > 1e9) break;
if (x % 3 == 0) x /= 3;
else x = 2*x+1;
steps++;
}
if (x != 1) cout << -1 << "\n";
else cout << steps+1 << "\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 ... |
