"Explanations" Luo Valley P5436 XR-2 [fate]

Problem Portal

Portal1: Luogu

Description

Zen want to know the fate of a size between him and his master. But how can we know it?

A Zen thought of a way, his first master agreement and a positive integer \ (n \) , then they each want no more than a heart \ (n \) positive integer.

A Zen thought, and the greater his master thought the least common multiple of two numbers, it means that the larger the fate between him and his master.

Master feels that this approach is appropriate, but he wants to know the maximum would be the least common multiple of the two numbers is.

Master of mathematics is not very good, so he asked a Zen. A Zen also think this question is very difficult, he wants you to tell him the answer.

Input

The first line of a positive integer \ (T \) , represents the number of data sets.

The next \ (T \) lines, each a positive integer \ (n-\) , represents a positive integer and a master agreed Zen.

Output

For each set of data, a line a positive integer representing the answer.

Sample Input

1
3

Sample Output

6

Solution

First, \ (\ GCD (X, X -. 1). 1 = \) , so \ (n-\) in the range of the least common multiple of the maximum must be \ (\ mathrm {lcm} ( n, n - 1) = n \ Times (the n-- 1) \) , then the answer is \ (the n-\ Times (the n-- 1) \) .

Particularly, when the \ (n = 1 \) when, because \ (n--. 1 = 0 \) , so the maximum is only \ (\ mathrm} {LCM (. 1,. 1) =. 1 \) .

Code

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long LL;
int T;
LL n;
int main() {
    scanf("%d", &T);
    while (T--) {
        scanf("%lld", &n);//考虑到后面还需相乘,会爆int
        if (n != 1) printf("%lld\n", n * (n - 1)); else printf("1\n");//特判
    }
    return 0;
}

Guess you like

Origin www.cnblogs.com/shenxiaohuang/p/11221074.html