java蝴蝶效应
来源:互联网 发布:linux python 编辑器 编辑:程序博客网 时间:2024/04/28 19:19
蝴蝶效应
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
蝴蝶效应是气象学家洛伦兹1963年提出来的。其大意为:一只南美洲亚马孙河流域热带雨林中的蝴蝶,偶尔扇动几下翅膀,可能在两周后引起美国德克萨斯引起一场龙卷风。其原因在于:蝴蝶翅膀的运动,导致其身边的空气系统发生变化,并引起微弱气流的产生,而微弱气流的产生又会引起它四周空气或其他系统产生相应的变化,由此引起连锁反应,最终导致其他系统的极大变化。此效应说明,事物发展的结果,对初始条件具有极为敏感的依赖性,初始条件的极小偏差,将会引起结果的极大差异。
我们将问题简化为方程 f(x) = (a*f(max(0,x-b)) + c*f(max(0,x-d)))%1000000007。
现在给出不同的f(0)和n以及参数a,b,c,d,计算出f(n)。
Input
多组输入。
对于每组数据,有六个个整数n,f0(1 <= n <= 10000,1 <= f0 <= 10000),a,b,c,d(1 <= a,b,c,d <= 10000)。
Output
对于每组数据输出f(n)。
Example Input
1 2 3 4 5 6
Example Output
16
Hint
Author
zmx
import java.util.*;import java.math.*;public class Main { public static long f0,a,b,c,d;//定义长整型 public static long fun[] = new long[20000];public static void main(String[] args) {Scanner input = new Scanner(System.in);while(input.hasNextInt()){for(int i=0;i<10010;i++){fun[i]=-1;//用数组保存更省时}int n = input.nextInt();fun[0] = input.nextInt();a = input.nextInt();b = input.nextInt();c = input.nextInt();d = input.nextInt();f(n);System.out.println(fun[n]);}}public static long f(int x){ if(fun[x]!=-1)return fun[x]%1000000007; else{fun[x] = (a*(f((int)Math.max(0,x-b))%1000000007)+c*(f((int)Math.max(0,x-d))%1000000007))%1000000007; return fun[x]%1000000007; }}}
1 0
- java蝴蝶效应
- java蝴蝶效应
- ^蝴蝶效应^
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 蝴蝶效应
- 【蝴蝶效应】
- 蝴蝶效应---。。。
- Maven私有库和本地库的安装与配置
- [BZOJ3211&3038][上帝造题的七分钟2&花神游历各国][线段树]
- SVM、LIBSVM、LIBLINEAR写的不错的博文
- Mysql
- 任务堆栈
- java蝴蝶效应
- Celery架构
- in、or、exists区别
- 搭建自己的Spring Initializr服务器
- 一起来学内存(二)
- 每日打卡 2017.03.07 POJ题目分类 水题
- kmp
- 更好的理解git rebase git merge
- ASP.NET MVC5 网站开发实践