結果
問題 | No.76 回数の期待値で練習 |
ユーザー |
![]() |
提出日時 | 2014-11-23 23:53:38 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,123 bytes |
コンパイル時間 | 849 ms |
コンパイル使用メモリ | 91,268 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2025-01-02 20:44:52 |
合計ジャッジ時間 | 7,208 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 1 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:59:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d", &t); | ~~~~~^~~~~~~~~~ main.cpp:63:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 63 | 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 j,int sum,int kai){ if (sum >= n){ m += kai; countt++; return; } if (j == 6){ if ((n-sum) % 6 == 0){ countt++; m+=kai+((n-sum)/6); } else{ countt++; m += kai + ((n - sum) / 6 )+1; } return; } else{ for (int k = 0; ; k++){ dfs(j + 1, sum + j*k, kai+k); if (j*k + sum >= n){ break; } } return; } } int main(){ scanf("%d", &t); while (t--){ m = 0; countt = 0; scanf("%d", &n); dfs(1, 0,0); double ans = (double)m / (double)countt; printf("%.7f\n", ans); } return 0; }