結果

問題 No.3031 (物理学)長距離相互作用
ユーザー Hoi_koroHoi_koro
提出日時 2018-03-02 13:58:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,146 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 168,360 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 23:02:53
合計ジャッジ時間 2,521 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    double q[4][4][4]={};
    double ans = 0.0;
    void solve(){
        cin >> q[0][0][0];
        cin >> q[0][0][2];
        cin >> q[0][2][0];
        cin >> q[0][2][2];
        cin >> q[2][0][0];
        cin >> q[2][0][2];
        cin >> q[2][2][0];
        cin >> q[2][2][2];

        cin >> q[1][1][1];
        cin >> q[1][1][3];
        cin >> q[1][3][1];
        cin >> q[1][3][3];
        cin >> q[3][1][1];
        cin >> q[3][1][3];
        cin >> q[3][3][1];
        cin >> q[3][3][3];

        double e1 = 0.0;
        int ub = 10;
        int lb = -ub;
        double rmax = ub;
        double pi = acos(-1.0);
        double sigma = 0.478942;
        DBG(1.0/sqrt(2.0*pi)+0.08)
        for(int i=lb; i<=ub; ++i){
            for(int j=lb; j<=ub; ++j){
                for(int k=lb; k<=ub; ++k){
                    if(abs(i)+abs(j)+abs(k)>rmax-1e-10)continue;
                    for(int d=0; d<=3; ++d){
                        for(int e=0; e<=3; ++e){
                            for(int f=0; f<=3; ++f){
                                if(i==0 and j==0 and k==0 and d==0 and e==0 and f==0)continue;
                                e1 += q[d%4][e%4][f%4]*erfc(dist(i,j,k,d,e,f)/sqrt(2.0)/sigma)/dist(i,j,k,d,e,f);

                            }
                        }
                    }
                    DBG(i,j,k,e1)
                }
            }
        }
        ub = 10;
        lb = -ub;
        rmax = ub;
        double e2 = 0.0;
        for(int i=lb; i<=ub; ++i){
            cerr<<i<<"\n";
            for(int j=lb; j<=ub; ++j){
                for(int k=lb; k<=ub; ++k){
                    if(i==0 and j == 0 and k==0)continue;
                    if(abs(i)+abs(j)+abs(k)>rmax-1e-10)continue;
                    double tmp = exp(-2.0*pi*pi*g(i,j,k)*sigma*sigma)/pi/g(i,j,k);
                    double tmp2 = 0.0;
                    for(int d=0; d<=3; ++d){
                        for(int e=0; e<=3; ++e){
                            for(int f=0; f<=3; ++f){
                                tmp2+=q[d%4][e%4][f%4]*cos(2.0*pi*(i*d+j*e+k*f)/4.0);
                            }
                        }
                    }
                    e2+=tmp*tmp2/pi;
                }
            }
        }

        double e3 = q[0][0][0]*sqrt(2.0/pi)/sigma;
        cerr<<e1 <<"\n";
        cerr<<e2 <<"\n";
        cerr<<e3 <<"\n";
        cout <<fixed << setprecision(10)<< e1+e2-e3 <<"\n";
    }
    double dist(double a, double b, double c,double d,double e, double f){
        return sqrt(pow(a+d/4.0,2.0)+pow(b+e/4.0,2.0)+pow(c+f/4.0,2.0));
    }
    double g(double a, double b, double c){
        return a*a+b*b+c*c;
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    Problem::Solver sol;
    sol.solve();
    Problem::Writer::write();
    return 0;
}

0