結果
問題 |
No.8031 (物理学)長距離相互作用
|
ユーザー |
![]() |
提出日時 | 2018-02-28 21:42:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,291 bytes |
コンパイル時間 | 761 ms |
コンパイル使用メモリ | 75,448 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 21:11:02 |
合計ジャッジ時間 | 42,669 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 8 |
ソースコード
#include<algorithm> #include<iostream> #include<vector> #include<cmath> using namespace std; typedef long long lint; typedef vector<int>vi; typedef pair<int,int>pii; #define rep(i,n)for(int i=0;i<(int)(n);++i) double q[4][4][4]; const int R=100; double calc(int low,int high,double decfac,bool trunc){ double volt=0.0; for(int i=low;i<=high;++i){ for(int j=low;j<=high;++j){ for(int k=low;k<=high;++k){ rep(l,4){ double x=4*i+l; if(trunc&&x>4*R)continue; rep(m,4){ double y=4*j+m; if(trunc&&y>4*R)continue; rep(nn,2){ int n=2*nn+((l+m)%2); double z=4*k+n; if(trunc&&z>4*R)continue; double fac=1; #define dec(x) if(x==4*low||x==4*high)fac*=decfac; dec(x); dec(y); dec(z); double sq=sqrt(x*x+y*y+z*z)/4; if(sq==0)continue; volt+=q[l][m][n]/sq*fac; } } } } } } return volt; } int main(){ rep(i, 8) { int u = 2 * (i / 4); int v = 2 * (i / 2 % 2); int w = 2 * (i % 2); cin>>q[u][v][w]; } rep(i, 8) { int u = 2 * (i / 4) + 1; int v = 2 * (i / 2 % 2) + 1; int w = 2 * (i % 2) + 1; cin>>q[u][v][w]; } double volt=calc(-R,R,0.5,true); double volt_notrunc=calc(-R,R,1,false); printf("%.15f\n",(volt+volt_notrunc)/2); }