結果
問題 | No.1180 無限和 |
ユーザー |
|
提出日時 | 2020-11-27 09:07:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 575 bytes |
コンパイル時間 | 550 ms |
コンパイル使用メモリ | 66,036 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-23 21:23:25 |
合計ジャッジ時間 | 2,124 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 38 |
コンパイルメッセージ
main.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 29 | main() | ^~~~
ソースコード
#include<iostream>using namespace std;int N;double ans;int K[50];const int LIM=20;int cnt[LIM+1];double fac[51];void dfs(int id,int rest,int mn){if(id==N){double A=1,B=0;for(int i=0;i<N;i++)A*=K[i]*K[i];for(int i=0;i<N;i++)B+=A/K[i]/K[i];double now=fac[N]/B/K[0]/K[0];for(int i=0;i<=LIM;i++)now/=fac[cnt[i]];ans+=now;return;}for(int i=mn;(N-id)*i<=rest;i++){K[id]=i;cnt[i]++;dfs(id+1,rest-i,i);cnt[i]--;}}main(){cin>>N;fac[0]=1;for(int i=1;i<=N;i++)fac[i]=fac[i-1]*i;dfs(0,N+LIM-1,1);cout<<(int)ans<<endl;}