結果
問題 |
No.76 回数の期待値で練習
|
ユーザー |
![]() |
提出日時 | 2014-11-24 00:20:32 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 890 bytes |
コンパイル時間 | 897 ms |
コンパイル使用メモリ | 94,444 KB |
実行使用メモリ | 22,948 KB |
最終ジャッジ日時 | 2025-01-02 21:00:33 |
合計ジャッジ時間 | 19,345 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%d", &t); | ~~~~~^~~~~~~~~~ main.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cctype> #include<cstdlib> #include<algorithm> #include<bitset> #include<vector> #include<list> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<sstream> #include<fstream> #include<iomanip> #include<ctime> #include<complex> #include<functional> #include<climits> #include<cassert> #include<iterator> using namespace std; int t; int n; long long int countt = 0; long long int m; void dfs(int sum,int kai){ if (sum <= 0){ countt++; m += kai; return; } for (int j = 1; j <= 6; j++){ dfs(sum - j, kai+1); } return; } int main(){ scanf("%d", &t); while (t--){ m = 0; countt = 0; scanf("%d", &n); dfs(n,0); double ans = (double)m / (double)countt; printf("%.7f\n", ans); } return 0; }