import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int a = cin.nextInt();
int b = cin.nextInt();
System.out.println(a + b);
}
}
—————————————————————————————————————————————————————
//package text;
import java.util.*;
import java.math.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
BigInteger a = cin.nextBigInteger();
BigInteger b = cin.nextBigInteger();
BigInteger c = a.add(b);
System.out.println(c);
}
}
—————————————————————————————————————————————————————
import java.util.*;
public class Main{
static int[][] dp = new int[1010][1010];
static int[][] pos = new int[1010][1010];
static String a = "!", b = "#", str = new String();
public static void Print(int i, int j){
if(i == -1 || j == -1) return;
if(pos[i][j] == 1){
Print(i-1, j-1);
System.out.print(a.charAt(i));
}
else if (pos[i][j] == 2) Print(i-1, j);
else Print(i, j-1);
}
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
str = cin.nextLine();
a += str;
str = cin.nextLine();
b += str;
int l1 = a.length();
int l2 = b.length();
for(int i = 1; i < l1; i++){
for(int j = 1; j < l2; j++){
if(a.charAt(i) == b.charAt(j)){
dp[i][j] = dp[i-1][j-1] + 1;
pos[i][j] = 1;
}
else{
dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
if(dp[i-1][j] > dp[i][j-1]) pos[i][j] = 2;
else pos[i][j] = 3;
}
}
}
Print(l1-1, l2-1);
}
}
—————————————————————————————————————————————————————
import java.awt.print.PrinterGraphics;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
long n = cin.nextLong();
long p = cin.nextLong();
long ans = 1;
for(int i = 2; i <= n; i++){
ans = ans * i % p;
}
ans %= p;
System.out.println(ans);
}
}
—————————————————————————————————————————————————————
import java.awt.print.PrinterGraphics;
import java.util.*;
public class Main{
public static long Gcd(long a, long b){
return b == 0 ? a : Gcd(b, a % b);
}
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
long a = cin.nextLong();
long b = cin.nextLong();
System.out.println(Gcd(a, b));
}
}
—————————————————————————————————————————————————————
import java.util.*;
public class Main{
public static long Gcd(long a, long b){
return b == 0 ? a : Gcd(b, a % b);
}
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
long a = cin.nextLong();
long b = cin.nextLong();
System.out.println(a * b / Gcd(a, b));
}
}
—————————————————————————————————————————————————————
import java.lang.reflect.Array;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i ++)
a[i] = cin.nextInt();
Arrays.sort(a);
for (int i = 0; i < n; i ++)
System.out.println(a[i]);
}
}
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
BigInteger a = cin.nextBigInteger();
BigInteger b = cin.nextBigInteger();
BigInteger c = a.multiply(b);
System.out.println(c);
}
}
—————————————————————————————————————————————————————
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Main{
public static long qkm(long a, long b, long c){
long base = 1;
while(b > 0){
a = a % c;
if((b & 1) == 1) base = base * a % c;
b = b >> 1;
a = a * a % c;
}
return base;
}
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
long a = cin.nextLong();
long b = cin.nextLong();
long c = cin.nextLong();
long ans = qkm(a, b ,c);
System.out.println(ans);
}
}
—————————————————————————————————————————————————————
import java.lang.reflect.Array;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
long[] a = new long[n+1];
for(int i = 1; i <= n; i ++)
a[i] = cin.nextLong();
long[] dp = new long[n+1];
long maxx = 0;
for(int i = 1; i <= n; i++){
dp[i] = Math.max(dp[i-1] + a[i], a[i]);
maxx = Math.max(dp[i], maxx);
}
System.out.println(maxx);
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
BigInteger ans = BigInteger.valueOf(1);
for(int i = 2; i <= n; i++){
ans = ans.multiply(BigInteger.valueOf(i));
}
System.out.println(ans);
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
double Pi = Math.acos(-1.0);
double e = 2.718281828459;
int n = cin.nextInt();
int ans = 0;
if(n == 1) ans = 1;
else ans = (int)(0.5 * Math.log10(2.0*Pi*n) + n* Math.log10(n*1.0/e) + 1);
System.out.println(ans);
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
while(T-- > 0){
int n = cin.nextInt();
int k = cin.nextInt();
if(n % (k+1) == 0) System.out.println("B");
else System.out.println("A");
}
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int n = cin.nextInt();
int ans = 0;
for(int i = 0 ; i < n; i++){
int x = cin.nextInt();
ans = ans ^ x;
}
if(ans == 0) System.out.println("B");
else System.out.println("A");
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
while(T-- > 0){
int x = cin.nextInt();
int y = cin.nextInt();
if(x > y) {
int t = x;
x = y;
y = t;
}
int temp = (int)(Math.floor((y-x) * (1+Math.sqrt(5.0))/2.0));
if(temp == x) System.out.println("B");
else System.out.println("A");
}
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
int ans = 0;
int n = cin.nextInt();
int k = cin.nextInt();
for(int i = 2; i <= n; i++)
ans = (ans + k) % i;
System.out.println(ans + 1);
}
}
—————————————————————————————————————————————————————
import java.util.*;
import java.math.*;
import java.io.*;
public class Main{
public static void main(String[] args){
Scanner cin = new Scanner(System.in);
String str = cin.nextLine();
int len = str.length();
char[] s = str.toCharArray();
int[] a = new int[len];
int[] b = new int[len];
int maxx = -1;
for(int i = 0; i < len; i++){
a[i]++;
int j = i - 1, k = i + 1;
while(j >= 0 && k < len){
if(s[j] == s[k]) a[i] += 2;
else break;
j--; k++;
}
int w = i, l = i + 1;
while(w >= 0 && l < len) {
if(s[w] == s[l]) b[i] += 2;
else break;
w--; l++;
}
}
Arrays.sort(a);
Arrays.sort(b);
System.out.printf("%d\n", Math.max(a[len-1], b[len-1]));
}
}
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————
—————————————————————————————————————————————————————