Another Contest 7 Problem 1 - Lonely Users

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 0.25s
Memory limit: 256M

Problem type

Ren has recently created a website, Ternary Search, which he intends on turning into the premier platform for competitive programmers to talk about anything.

In order to facilitate conversation between different users, Ren is working on a new feature called "friends". The feature will allow two distinct users to be friends. Ren is working on a prototype of this feature right now, so at present, all users are friends with Ren, and these are the only friendships present on the platform.

Including Ren, there are N users on the platform. Ren eventually wants to track a metric which he calls the "lonely user" metric, which is a count of how many users have exactly one friend. With the prototype the way it is now, how many users are lonely users?

Constraints

1T104

1N109

Input Specification

The first line contains a single positive integer T, the number of test cases.

T lines follow, each line containing a single positive integer N, the number of users presently on the platform.

Output Specification

Output T lines. On the ith line, output the number of lonely users for the ith test case.

Sample Input

Copy
3
1
10
100

Sample Output

Copy
0
9
99

Comments


  • 0
    justinnova0915  commented on Nov. 30, 2024, 7:38 p.m.

    Use the magic of friendship~


  • 2
    Viv_CCGS  commented on Oct. 27, 2021, 8:49 a.m.

    Gets every test case right except the last one :(


    • 4
      justin_g_20  commented on Oct. 28, 2021, 9:18 a.m.

      Think about how many friendships Ren will have