蝴蝶效应--Java

版权声明:转载请注明出处 https://blog.csdn.net/weixin_42981803/article/details/82819869

原题链接

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner reader = new Scanner(System.in);
		long[] s=new long[10003];
		int f,a,b,c,d;
		int i;
		int n;
		while(reader.hasNextInt()) {
			n=reader.nextInt();
			f=reader.nextInt();
			a=reader.nextInt();
			b=reader.nextInt();
			c=reader.nextInt();
			d=reader.nextInt();
			s[0]=f;
			for(i=1;i<=n;i++) {
				s[i]= (a*s[Math.max(0,i-b)] + c*s[Math.max(0,i-d)])%1000000007;
			}
			System.out.println(s[n]);
		}
		reader.close();
	}
}

猜你喜欢

转载自blog.csdn.net/weixin_42981803/article/details/82819869