2020 autumn recruit Java / R & D program post title Collection

Determine the number of dreams

Title Description

Dream defined number, the number of each of the squares and has add operation occurs when the number of cycles in a dream was
enter a positive integer, it is determined whether the number is a dream
Example: 19
1 ^ 9 ^ 2 + 2 = 82
. 8 ^ 2 + 2 ^ 2 = 68
^ 6 2 + 2 = 100 8 ^
1 ^ 0 ^ 2 + 2 + 2 ^ 0 = 1
i.e. the number 19 is a dream

coding

  // TODO

Rye escape

Title Description

Master lived in a village, an avalanche day Master running speed of 13m / s, using magic 1s move 50m, but will spend 10 Magic
Master initial mana M, village distance safely is S, the time avalanche arrival T, the Master recovery magic rate of 4:00 / s, but only standing still can recover

Entry

Input line, comprising three non-negative integers M, S, T

Export

Two output lines
of the first line of output "Yes", "No", indicates whether the safe arrival
or non-arrival of the second row reaches the output time of arrival of the maximum distance

coding

// 代码为自行编写,可能存在 Bug
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int m = scn.nextInt(), s = scn.nextInt(), t = scn.nextInt();
        // count:初始魔法值能用几次 tAns:记录使用的时间 sAns:记录走过的路程 flag:此处标记剩余魔法值是否为 4 的倍数
        int count = m/10, sAns = 0, tAns = 0, tt = 0, flag = (10-m%10)%10%4 == 0 ? 0 : 1;
        if(m%10 > 1 && m%10/4 + flag <= t) {                 // tt记录下恢复到至少 10 点魔法值所需时间
            tt = m%10 / 4 + flag;
        }
        flag = s%50 == 0 ? 0 : 1;                            // 此处标记路程是否为 50 的倍数
        count = Math.min(count, Math.min(s/50+flag,t));
        sAns += count * 50;
        tAns += count;
        if(tt != 0 && tt+1 <= t-tAns && tt*13 + sAns < s) {  // 存在多余魔法值 未被淹没 使用等待的时间直接走不会到达目的地
            sAns += 50;
            tAns += tt + 1;
        }
        flag = (s-sAns)%13 == 0 ? 0 : 1;                     // 此处标记剩余路程为 13 的倍数
        count = Math.min((s-sAns)/13+flag, (t-tAns));
        sAns += count * 13;
        tAns += count;
        if(sAns < s) {
            System.out.println("No");
            System.out.println(sAns);
        } else {
            System.out.println("Yes");
            System.out.println(tAns);
        }
    }
}

Travel Route

Title Description

There are cities, M N Block route, which now want to go to Marco Polo R cities, please help him develop a shortest route.
Course for undirected edges, to ensure that no heavy side

Entry

The first input line N, M, R (2 < = N <= 200,1 <= M <= 500,2 <= R <= min (22, N)
a second input line number R cities
M rows after per line x, y, z represents the distance between the cities and urban y z x m (z <= 10000)

Export

The shortest distance route

coding

  // TODO

To Be Continue...

Guess you like

Origin www.cnblogs.com/qq188380780/p/11480936.html