9/2/25, 10:26 AM Problem - 2074C - Codeforces
|
stdfloat | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST
Codeforces Round 1009 (Div. 3)
C. XOR and Triangle Finished
time limit per test: 2 seconds Practice
memory limit per test: 256 megabytes
This time, the pink soldiers have given you an integer x (x ≥ 2 ).
Please determine if there exists a positive integer y that satisfies the following conditions. → Virtual participation
y is strictly less than x . Virtual contest is a way to take part in past contest,
as close as possible to participation on time. It is
There exists a non-degenerate triangle with side lengths x , y, x ⊕ y . Here, ⊕ denotes the bitwise XOR
∗
supported only ICPC mode for virtual contests. If
you've seen these problems, a virtual contest is not
operation. for you - solve these problems in the archive. If you
just want to solve some problem from a contest, a
virtual contest is not for you - solve this problem in
Additionally, if there exists such an integer y, output any. the archive. Never use someone else's code, read
the tutorials or communicate with other person
∗
A triangle with side lengths a , b, c is non-degenerate when a + b , ,
> c a + c > b b + c > a . during a virtual contest.
Input Start virtual contest
Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 2000 ). The
description of the test cases follows.
9
→ Clone Contest to Mashup
The only line of each test case contains a single integer x (2 ≤ x ≤ 10 ).
Output → Submit?
For each test case, print one integer on a separate line. The integer you must output is as follows:
Language: GNU G++20 13.2 (64 bit, winlibs)
If there exists an integer y satisfying the conditions, output the value of y (1 ≤ y < x );
Otherwise, output −1. Choose
Choose File No file chosen
file:
If there exist multiple integers that satisfy the conditions, you may output any.
Submit
Example
input Copy
→ Contest materials
7
5
2 Announcement (en)
6
Tutorial (en)
3
69
4
420 → CF GetRating
output Copy
*1100
3
-1 Show All Tags
5
-1 Contest Standings
66
-1
320
Note
In the first test case, there exists a non-degenerate triangle with side lengths 3 , 5 , and 3 ⊕ 5 = 6 . Therefore,
y = 3 is a valid answer.
In the second test case, 1 is the only possible candidate for y, but it cannot make a non-degenerate triangle.
Therefore, the answer is −1.
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Sep/02/2025 10:24:52UTC+5 (h1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions
Supported by
https://codeforces.com/problemset/problem/2074/C 1/1