結果
問題 | No.66 輝け☆全国たこやき杯 |
ユーザー |
![]() |
提出日時 | 2018-04-18 19:34:48 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 933 bytes |
コンパイル時間 | 124 ms |
コンパイル使用メモリ | 24,448 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-27 04:32:53 |
合計ジャッジ時間 | 721 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
main.c: In function ‘run’: main.c:13:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d",&m); | ^~~~~~~~~~~~~~ main.c:17:22: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | for(i=0;i<len;i++) scanf("%d",a+i); | ^~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>#include<stdlib.h>#include<math.h>typedef long long int int64;#define MAX(a,b) ((a)>(b)?(a):(b))#define MIN(a,b) ((a)<(b)?(a):(b))#define ABS(a) ((a)>(0)?(a):-(a))void run(void){int m;scanf("%d",&m);int len=1<<m;int *a=(int *)malloc(sizeof(int)*len);int i;for(i=0;i<len;i++) scanf("%d",a+i);double *now=(double *)malloc(sizeof(double)*len);double *next=(double *)malloc(sizeof(double)*len);for(i=0;i<len;i++) now[i]=1;for(i=1;i<=m;i++){int j;for(j=0;j<len;j++) next[j]=0;for(j=0;j<len;j+=(1<<i)){int x,y;for(x=j;x<j+(1<<(i-1));x++){for(y=j+(1<<(i-1));y<j+(1<<i);y++){int sx=a[x];int sy=a[y];double p=(double)sx*sx/(sx*sx+sy*sy);next[x]+=now[x]*now[y]*p;next[y]+=now[x]*now[y]*(1-p);}}}double *swap=now;now=next;next=swap;}printf("%.9lf\n",now[0]);}int main(void){run();return 0;}