wordpress全站静态,邯郸住房和城乡建设部网站,wordpress插件推荐,高端网站建设方案范文解题思路
由于对于一点不知道后面得花费#xff0c;所以无法决策当前是否要停下赚钱或要停下多久考虑一点#xff0c;可以由其左上方的所有点到达所以从往前推#xff0c;得出到的总花费然后考虑从之后不赚钱直接到最终所用次数和剩余钱若存在#xff0c;在后面点赚钱更优… 解题思路
由于对于一点不知道后面得花费所以无法决策当前是否要停下赚钱或要停下多久考虑一点可以由其左上方的所有点到达所以从往前推得出到的总花费然后考虑从之后不赚钱直接到最终所用次数和剩余钱若存在在后面点赚钱更优的情况则会被从到情况包含因为处理时已经是最优状态而状态的更新必然考虑了从到至于最优状态的选择次数越少越好在次数相同的情况下剩余钱越多越好由于若次数少可以通过增加次数换增加钱所以次数的优先级更高用的
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.Vector;//implements Runnable
public class Main{static long md(long)20020219;static long LinfLong.MAX_VALUE/2;static int infInteger.MAX_VALUE/2;static int M10000;static int N300;static int n0;static int m0;static int k0;staticclass Node{long x;//timelong y;//moneypublic Node() {xLinf;y0;}void get(long u,long v) {xu;yv;}}public static void main(String[] args) throws Exception{AReader inputnew AReader();PrintWriter out new PrintWriter(new OutputStreamWriter(System.out)); int ninput.nextInt();long[][] pnew long[n1][n1];long[][] rnew long[n1][n1];long[][] dnew long[n1][n1];for(int i1;in;i) {for(int j1;jn;j) {p[i][j]input.nextLong();}}for(int i1;in;i) {for(int j1;jn;j) {r[i][j]input.nextLong();}}for(int i1;in;i) {for(int j1;jn;j) {d[i][j]input.nextLong();}}Node[][] fnew Node[n1][n1];for(int i1;in;i) {for(int j1;jn;j) {f[i][j]new Node();}}f[1][1].get(0, 0);;long[][] disnew long[n1][n1];for(int i1;in;i) {for(int j1;jn;j) {for(int x1;xi;x) {Arrays.fill(dis[x], Linf);}dis[i][j]0;for(int xi;x1;--x) {for(int yj;y1;--y) {if(xi) dis[x][y]Math.min(dis[x][y], d[x][y]dis[x1][y]);if(yj) dis[x][y]Math.min(dis[x][y], r[x][y]dis[x][y1]);long cMath.max(0, dis[x][y]-f[x][y].y(p[x][y]-1))/p[x][y];//上取整long tf[x][y].xci-xj-y;long mf[x][y].yp[x][y]*c-dis[x][y];if(tf[i][j].x||tf[i][j].xmf[i][j].y) {f[i][j].get(t, m);}}}}}out.print(f[n][n].x);out.flush();out.close();}
// public static final void main(String[] args) throws Exception {
// new Thread(null, new Main(), 线程名字, 1 27).start();
// }
// Override
// public void run() {
// try {
// //原本main函数的内容
// solve();
//
// } catch (Exception e) {
// }
// }
// static
// class Node{
// int x;
// int y;
// public Node(int u,int v) {
// xu;
// yv;
// }
// Override
// public boolean equals(Object o) {
// if (this o) return true;
// if (o null || getClass() ! o.getClass()) return false;
// Node may (Node) o;
// return x may.x ymay.y;
// }
//
// Override
// public int hashCode() {
// return Objects.hash(x, y);
// }
// }staticclass AReader{ BufferedReader bf;StringTokenizer st;BufferedWriter bw;public AReader(){bfnew BufferedReader(new InputStreamReader(System.in));stnew StringTokenizer();bwnew BufferedWriter(new OutputStreamWriter(System.out));}public String nextLine() throws IOException{return bf.readLine();}public String next() throws IOException{while(!st.hasMoreTokens()){stnew StringTokenizer(bf.readLine());}return st.nextToken();}public char nextChar() throws IOException{//确定下一个token只有一个字符的时候再用return next().charAt(0);}public int nextInt() throws IOException{return Integer.parseInt(next());}public long nextLong() throws IOException{return Long.parseLong(next());}public double nextDouble() throws IOException{return Double.parseDouble(next());}public float nextFloat() throws IOException{return Float.parseFloat(next());}public byte nextByte() throws IOException{return Byte.parseByte(next());}public short nextShort() throws IOException{return Short.parseShort(next());}public BigInteger nextBigInteger() throws IOException{return new BigInteger(next());}public void println() throws IOException {bw.newLine();}public void println(int[] arr) throws IOException{for (int value : arr) {bw.write(value );}println();}public void println(int l, int r, int[] arr) throws IOException{for (int i l; i r; i ) {bw.write(arr[i] );}println();}public void println(int a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(int a) throws IOException{bw.write(String.valueOf(a));}public void println(String a) throws IOException{bw.write(a);bw.newLine();}public void print(String a) throws IOException{bw.write(a);}public void println(long a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(long a) throws IOException{bw.write(String.valueOf(a));}public void println(double a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}public void print(double a) throws IOException{bw.write(String.valueOf(a));}public void print(char a) throws IOException{bw.write(String.valueOf(a));}public void println(char a) throws IOException{bw.write(String.valueOf(a));bw.newLine();}}}