PlayStation india

All related to gaming in india

LightBlog

Breaking

Friday, 6 January 2023

January 06, 2023

A. Greatest Convex codeforces solution in c++ || Codeforces Round #842 (Div. 2)

 A. Greatest Convex

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an integer k. Find the largest integer x, where 1x<k, such that x!+(x1)! is a multiple of  k, or determine that no such x exists.

 y! denotes the factorial of y, which is defined recursively as y!=y(y1)! for y1 with the base case of 0!=1. For example, 5!=543210!=120.

 If a and b are integers, then a is a multiple of b if there exists an integer c such that a=bc. For example, 10 is a multiple of 5 but 9 is not a multiple of 6.

Input

The first line contains a single integer t (1t104) — the number of test cases. The description of test cases follows.

The only line of each test case contains a single integer k (2k109).

Output

For each test case output a single integer — the largest possible integer x that satisfies the conditions above.

If no such x exists, output 1.

CODE OF THE QUESTION -------

  int n;

cin >>n;

cout<<n-1<<endl;