CF23B.Party

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.

What is the maximum amount of people that could stay at the party in the end?

有 nn 个人来到一场聚会。随后,所有在聚会现场没有朋友的人离开了。接着,所有在当时恰好有 1 个朋友(该朋友也仍在场)的人也离开了。然后,所有在当时恰好有 2,3,…,n−12, 3, \dots, n-1 个朋友(这些朋友也都仍在场)的人依次照此规则离开。

最终,聚会上最多可能剩下多少人?

输入格式

The first input line contains one number t — amount of tests (1 ≤ t ≤ 105). Each of the following t lines contains one integer number n (1 ≤ n ≤ 105).

第一行输入包含一个数字 tt —— 测试用例的数量(1 ≤ t ≤ 1051 \leq t \leq 10^5)。接下来的 tt 行中,每行包含一个整数 nn(1 ≤ n ≤ 1051 \leq n \leq 10^5)。

输出格式

For each test output in a separate line one number — the maximum amount of people that could stay in the end.

对于每个测试用例,输出一行一个数字——最终可能留下的最多人数。

输入输出样例

  • 输入#1

    1
    3

    输出#1

    1

输入解题思路,AI测评打分。不知道怎么写?

首页