解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class llq1{
static double [][]dp=new double[105][10005];
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int a=s.nextInt();
int b=s.nextInt();
int x=s.nextInt();
int len=b-a+1;
dp[0][0]=1;
for(int i=1;i<=n;i++) {
for(int j=a*i;j<=x;j++) {
for(int k=a;k<=b;k++) {
if(j>=k)
dp[i][j]+=dp[i-1][j-k]/len;
else break;
}
}
}
System.out.printf("%.4f",dp[n][x]);
}
}
0.0分
2 人评分
C二级辅导-计负均正 (C语言代码)浏览:581 |
C二级辅导-公约公倍 (C语言代码)浏览:1510 |
A+B for Input-Output Practice (VII) (C++代码)浏览:615 |
【出圈】 (C语言代码)浏览:796 |
简单的for循环浏览:1410 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:596 |
C语言程序设计教程(第三版)课后习题9.1 (C语言代码)浏览:682 |
The 3n + 1 problem (C语言代码)浏览:554 |
K-进制数 (C语言描述,蓝桥杯)浏览:925 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:489 |