其中
#include <iostream> using namespace std; int main(){ long long n; cin>>n; cout<<n*(n-1)-1; }
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String next = sc.next();
int a = Integer.parseInt(next);
int b = a-1;
String a1 = a+"";
String b1 = b+"";
BigInteger a2 = new BigInteger(a1);
BigInteger b2 = new BigInteger(b1);
BigInteger one = new BigInteger("1");
BigInteger result = (a2.multiply(b2).subtract(one));
System.out.println(result);
} /* 最小公倍数与最大公约数,求n下任意两个数的(最小公倍数-最大公约数)的最大值 */
#include <bits/stdc++.h>
using namespace std;
int main()
{
unsigned long long int n;
cin >> n;
unsigned long long int max=0;
while(n>1){
if((n * (n-1) -1) > max){
max=n * (n-1) -1;
}
n--;
}
cout << max << endl;
return 0;
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long n = in.nextLong();
in.close();
System.out.println((n * (n - 1)) / gcd(n, n - 1) - gcd(n, n - 1));
}
public static long gcd(long a, long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
} import java.util.Scanner;
import java.math.BigInteger;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
//真的容易超时,还得是大整数相乘啊
public static void process(String n) {
if (n.charAt(0) == '1') {
System.out.println(1);
return ;
}
BigInteger n1 = new BigInteger(n);
BigInteger n2 = new BigInteger(n);
BigInteger n3= n2.subtract(new BigInteger("1"));
BigInteger res=n1.multiply(n3).subtract(new BigInteger("1"));
System.out.println(res);
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
String n = in.next();
process(n);
}
}
}
// 哈哈哈 超时
public class Main {
public static void main(String[] args) {
long n=0;
Scanner in=new Scanner(System.in);
if(in.hasNextLong()){
n=in.nextLong();
}
long mr=Long.MIN_VALUE;
for(long a=1;a<=n;a++){
for(long b=1;b<=n;b++){
// 求最小公倍数
long x=gbshu(a, b);
// 求最小公约数
long y=(a*b)/x;
// 相减
mr=Math.max(mr, x-y);
}
}
System.out.println(mr);
}
public static long gbshu(long a , long b) {
//
if(a%2!=0&&b%2!=0&&a==b){
return a;
}
//
long ra=0;
long ca=0;
while(true){
if(a%2!=0){
ra=a;
break;
}else{
a=a/2;
ra=a;
ca++;
}
}
//
long rb=0;
long cb=0;
while(true){
if(b%2!=0){
rb=b;
break;
}else{
b=b/2;
rb=b;
cb++;
}
}
//
long c=Math.max(ca, cb);
long d=1;
for(long i=0;i<c;i++){
d*=2;
}
return ra*rb*d;
}
}