結果

問題 No.3031 (物理学)長距離相互作用
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-02-28 21:38:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,290 bytes
コンパイル時間 664 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 19:35:36
合計ジャッジ時間 14,760 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,115 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1,124 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,140 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=70;

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);
}
0