結果
| 問題 |
No.302 サイコロで確率問題 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-15 01:03:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 529 bytes |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 45,056 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 16:48:20 |
| 合計ジャッジ時間 | 5,184 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 7 RE * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:29: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=]
23 | printf("%.15f\n",probably(N,6,L,R));
| ~~~~^ ~~~~~~~~~~~~~~~~~
| | |
| double long double
| %.15Lf
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%lld%lld%lld",&N,&L,&R);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
long double probably(int n, int s, int l, int r){
vector<long double> a(s*(n+1)+1);
for(int i=1;i<=s;i++)a[i+s]=powl(1.0/s,n);
for(int e=0;e<n-1;e++)for(int i=s*n;i>=0;i--){
long double sum=0;
for(int j=i;j<i+s;j++)sum+=a[j];
a[i+s]=sum;
}
long double ret=0;
for(;l<=r;l++)ret+=a[s+l];
return ret;
}
int main(){
long long N,L,R;
scanf("%lld%lld%lld",&N,&L,&R);
if(N<10000){
printf("%.15f\n",probably(N,6,L,R));
}else{
return 1;
}
}