#5801. [NWRRC 2021] Halfway There

[NWRRC 2021] Halfway There

[NWRRC 2021] Halfway There

题目描述

Given an integer $n$, find the median of the list of all integers from $1$ to $n - 1$ that are coprime with $n$.

Recall that integers aa and bb are called coprime\textit{coprime} if their greatest common divisor is 1. The median\textit{median} of a list LL is defined to be the ∣L∣2\frac {|L|}{2}-th element of LL if ∣L∣|L| is even, and the ∣L∣+12\frac {|L|+1}{2}-th element of LL if ∣L∣|L| is odd. Here LL is assumed to be sorted in ascending order, ∣L∣|L| denotes the length of LL, and indices are 11-based.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^3$). Description of the test cases follows.

The only line of each test case contains a single integer nn (2≤n≤10182 \le n \le 10^{18}).

输出格式

For each test case, print a single integer --- the median of the list of integers from $1$ to $n - 1$ that are coprime with $n$.
3
6
10
19
1
3
9

提示

(暂无提示) 标签: P13635|2021|ICPC|NWRRC

来源

P13635|[NWRRC 2021] Halfway There