蝴蝶效应 sdutacm
2017-03-07 20:17
288 查看
蝴蝶效应
Time Limit: 1000MS Memory Limit: 65536KBSubmit Statistic Discuss
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
import java.util.*;
public class Main {
static int a, b, c, d;
static long f[] = new long[110000];
final static long mod = 1000000007;
public static void main(String[] args) {
long p;
int n;
Scanner cin = new Scanner(System.in);
while(cin.hasNext()){
for(int i = 0; i <= 100010; i++)
f[i] = 0;
n = cin.nextInt();
p = cin.nextLong();
a = cin.nextInt();
b = cin.nextInt();
c = cin.nextInt();
d = cin.nextInt();
f[0] = p;
long x = fou(n);
System.out.println(x);
}
}
public static long fou(int x){
if(x <= 0)
return f[0];
if(f[x] != 0)
return f[x];
f[x] = (a * fou(x - b) + c * fou( x - d)) % mod;
return f[x];
}
}
相关文章推荐
- 蝴蝶效应:混沌中的非线性
- 细节决定成败 ASP.NET中的蝴蝶效应
- 信用社这些事儿(四)----张畏事件的蝴蝶效应
- 蝴蝶效应、青蛙现象、鳄鱼法则、鲇鱼效应、羊群效应、刺猬法则、手表定律、破窗理论、二八定律、木桶理论、马太效应
- 17. 蝴蝶效应
- 让幽默态度在工作上发挥蝴蝶效应
- 《青瓷》和现实:蝴蝶效应
- 由奶粉引起的蝴蝶效应(dambolo)
- 蝴蝶效应,青蛙现象,鳄鱼法则,鲇鱼效应,羊群效应,刺猬法则,手表定律,破窗理论,二八定律,木桶理论,马太效应,这些你都明白吗
- 产品经理必须知道的几大法则:蝴蝶效应、青蛙现象等
- 微软收购诺基亚 百年老店必将引发蝴蝶效应
- 蝴蝶效应,青蛙现象,鳄鱼法则,鲇鱼效应,羊群效...
- 蝴蝶效应
- 细节决定成败 ASP.NET中的蝴蝶效应
- The two different ending of the movie butterfly effect----电影蝴蝶效应的两个不同结局
- 蝴蝶效应,鳄鱼法则,罗森塔尔效应,帕金森定律,手表定律,破窗理论,晕轮效应 ,霍桑效应,二八定律,木桶理论,马太效应,踢猫效应
- 蝴蝶效应、青蛙现象、鳄鱼法则
- 蝴蝶效应
- [转]细节决定成败 ASP.NET中的蝴蝶效应
- 《青瓷》和现实:蝴蝶效应