LaLa_JUROU

244

import java.io.*;
import java.math.BigInteger;

public class Main{

static BigInteger a,b;
public static void main(String[] args) throws IOException{
//a + b
//a - b
System.out.println(a.subtract(b).toString());
//a * b
System.out.println(a.multiply(b).toString());
}
}


#### JAVA 代码

import java.io.*;
import java.math.BigInteger;

public class Main{

static BigInteger a,b;
public static void main(String[] args) throws IOException{
//a + b
//a - b
System.out.println(a.subtract(b).toString());
//a * b
System.out.println(a.multiply(b).toString());
}
}


import java.io.*;

public class Main{

static int n;
static long prime[] = new long[10001];//0存储当前长度
public static void main(String[] args) throws IOException{
long i = prime[(int)prime[0]];
String line;
n = Integer.parseInt(line);
if(prime[n] == 0) {
i ++;
}
while(prime[n] == 0) {
if(isPrime(i)) {
prime[0] ++;
prime[(int)prime[0]] = i;
}
i ++;
}
System.out.println(prime[n]);
}
}
static boolean isPrime(long number) {//判断是否为Prime
if(number < 4) {
return number > 1;
}
int sqrt = (int) Math.sqrt(number);
for(int i = 2; i <= sqrt; i ++) {
if(number % 2 == 0 || number % i == 0) {
return false;
}
}
return true;
}
}


import java.io.*;
public class Main{

static String date1,date2;
public static void main(String[] args) throws IOException{
while((date1 = in.readLine()) != null && (date2 = in.readLine()) != null) {
System.out.println(Math.abs(getDays(date1) - getDays(date2)) + 1);
}
}
static long getDays(String date) {
long sum = 0;
int year = Integer.parseInt(date.substring(0, 4));
int month = Integer.parseInt(date.substring(4, 6));
int day = Integer.parseInt(date.substring(6, 8));
//年计算天
for(int i = 1; i < year; i ++) {
if((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0)){//判断是否闰年
sum += 366;
} else {
sum += 365;
}
}
//月计算天
for(int i = 1; i < month; i ++) {
if(i == 4 || i == 6 || i == 9 || i == 11) {
sum += 30;
} else if (i == 2) {
if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){//判断是否闰年
sum += 29;
} else {
sum += 28;
}
} else {
sum += 31;
}
}
sum += day;
return sum;
}
}


#### JAVA 代码

//DFS + 动态优化
import java.io.*;

public class Main{

static int a[][] = new int[6][6],sX,sY,eX,eY,min = (int)1e8,dx[],dy[];
static boolean mark[][] = new boolean[6][6];
public static void main(String[] args) throws IOException{
//分量
dx = new int[]{0,0,-1,1};//上下左右
dy = new int[]{-1,1,0,0};
for(int x = 0; x < 6; x ++){
for(int y = 0; y < 6; y ++){
a[x][y] = next();
}
}
sX = next();
sY = next();
eX = next();
eY = next();
dfs(sX,sY,0,1);
System.out.println(min);
}
static void dfs(int x,int y,int dept,int state){
if(x == eX && y == eY){
min = Math.min(min,dept);
}
//动态优化,如果这步已经大于当前最小值那么就不继续走
if(dept > min) {
return;
}
for(int i = 0; i < 4; i ++){
int X = x + dx[i];
int Y = y + dy[i];
if(X < 0 || X > 5 || Y < 0 || Y > 5){
continue;
}
if(!mark[X][Y]){
int addDept = a[X][Y] * state;
mark[X][Y] = true;
mark[X][Y] = false;
}
}

}
static int next() throws IOException{
in.nextToken();
return (int)in.nval;
}
}


//DFS + 动态优化
import java.io.*;

public class Main{

static int a[][] = new int[6][6],sX,sY,eX,eY,min = (int)1e8,dx[],dy[];
static boolean mark[][] = new boolean[6][6];
public static void main(String[] args) throws IOException{
//分量
dx = new int[]{0,0,-1,1};//上下左右
dy = new int[]{-1,1,0,0};
for(int x = 0; x < 6; x ++){
for(int y = 0; y < 6; y ++){
a[x][y] = next();
}
}
sX = next();
sY = next();
eX = next();
eY = next();
dfs(sX,sY,0,1);
System.out.println(min);
}
static void dfs(int x,int y,int dept,int state){
if(x == eX && y == eY){
min = Math.min(min,dept);
}
//动态优化,如果这步已经大于当前最小值那么就不继续走
if(dept > min) {
return;
}
for(int i = 0; i < 4; i ++){
int X = x + dx[i];
int Y = y + dy[i];
if(X < 0 || X > 5 || Y < 0 || Y > 5){
continue;
}
if(!mark[X][Y]){
int addDept = a[X][Y] * state;
mark[X][Y] = true;
mark[X][Y] = false;
}
}

}
static int next() throws IOException{
in.nextToken();
return (int)in.nval;
}
}


import java.io.*;

public class Main{

static int a[][] = new int[6][6],sX,sY,eX,eY,min = (int)1e8,dx[],dy[];
static boolean mark[][] = new boolean[6][6];
public static void main(String[] args) throws IOException{
//分量
dx = new int[]{0,0,-1,1};//上下左右
dy = new int[]{-1,1,0,0};
for(int x = 0; x < 6; x ++){
for(int y = 0; y < 6; y ++){
a[x][y] = next();
}
}
sX = next();
sY = next();
eX = next();
eY = next();
dfs(sX,sY,0,1);
System.out.println(min);
}
static void dfs(int x,int y,int dept,int state){
if(x == eX && y == eY){
min = Math.min(min,dept);
}
//动态优化,如果这步已经大于当前最小值那么就不继续走
if(dept > min) {
return;
}
for(int i = 0; i < 4; i ++){
int X = x + dx[i];
int Y = y + dy[i];
if(X < 0 || X > 5 || Y < 0 || Y > 5){
continue;
}
if(!mark[X][Y]){
int addDept = a[X][Y] * state;
mark[X][Y] = true;
mark[X][Y] = false;
}
}

}
static int next() throws IOException{
in.nextToken();
return (int)in.nval;
}
}


//Floyd算法 //逆序加入节点
import java.io.*;

public class Main{

static int n,a[][];
static long sum;
public static void main(String[] args) throws IOException{
n = next();
a = new int[n][n];
if(n == 1) {
System.out.println(0);
return; //特例
}
for(int i = 0; i < n; i ++) {//输入
for(int v = 0; v < n; v ++) {
a[i][v] = next();
}
}
int x = n - 1;
for(int y = n - 1; y > 0; y --, x --) {//迭代以x为起点的矩阵
update(y);
//累加到sum中
for(int b = x; b < n; b ++) {
for(int c = x; c < n; c ++) {
sum += a[b][c];
}
}
}

System.out.println(sum);
}
static void update(int v) {
for(int x = 0; x < n; x ++) {
for(int y = 0; y < n; y ++) {
if(a[x][y] > a[x][v] + a[v][y] ) {
a[x][y] = a[x][v] + a[v][y]; //x->v->y 以v为中转节点迭代
}
}
}
}

static int next() throws IOException{
in.nextToken();
return (int)in.nval;
}
}


  //字符串、模拟
import java.io.*;

public class Main{

static String start,end;
static char[] line;
public static void main(String[] args) throws IOException{
while(true) {
if(start.equals("ENDOFINPUT")) {//程序结束
return;
}
for(int i = 0; i < line.length; i ++) {
if(line[i] >= 65 && line[i] <= 90) {
line[i] = (char)((line[i] - 95) % 26 + 90);
}
}
System.out.println(new String(line));
}
}
}


#### JAVA 代码

import java.util.Scanner;

public class Main{
static Scanner in = new Scanner(System.in);

static int n,a;
public static void main(String[] args) {
n = in.nextInt();
while(n --> 0) {
a = in.nextInt();//贪心，全是鸡 or 鸡 + 1是最小值的优解，全是兔是最大值优解
System.out.println(a % 2 == 1 ? "0 0" : a % 4 == 0 ? a / 4 + " " + a / 2 : a / 4 + 1 + " " + a / 2);
}
}
}