洛谷 P1011 [NOIP1998 提高组] 车站
演草纸:
代码实现:
package com.java.test; import java.util.Scanner; public class Main { public static int t(int n){ if (n==1){ return 1; }else if (n==2){ return 1; } return t(n-1)+t(n-2); } public static int y(int a,int n,int m,int x){ int n2=n-1; int b=(m-(t(n2-2)+1)*a)/(t(n2-1)-1); n=x; int xren = t(n - 2) * a+ t(n - 1) * b + a - b; return xren; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a=sc.nextInt(); int n=sc.nextInt(); int m=sc.nextInt(); int x=sc.nextInt(); System.out.println(y(a,n,m,x)); } }

浙公网安备 33010602011771号