結果

問題 No.3031 (物理学)長距離相互作用
ユーザー PachicobuePachicobue
提出日時 2018-03-01 02:17:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,510 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 200,880 KB
実行使用メモリ 8,140 KB
最終ジャッジ日時 2023-08-26 19:54:29
合計ジャッジ時間 24,539 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;
constexpr ld PI = static_cast<ld>(3.1415926535898);

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

constexpr ld G = 0.1;
constexpr int MAX = 50;

constexpr ld X1[8] = {0, -0.5, 0, -0.5, 0, -0.5, 0, -0.5};
constexpr ld Y1[8] = {0, 0, -0.5, -0.5, 0, 0, -0.5, -0.5};
constexpr ld Z1[8] = {0, 0, 0, 0, -0.5, -0.5, -0.5, -0.5};

constexpr ld X2[8] = {-0.25, -0.75, -0.25, -0.75, -0.25, -0.75, -0.25, -0.75};
constexpr ld Y2[8] = {-0.25, -0.25, -0.75, -0.75, -0.25, -0.25, -0.75, -0.75};
constexpr ld Z2[8] = {-0.25, -0.25, -0.25, -0.25, -0.75, -0.75, -0.75, -0.75};

ld abs(const ld dx, const ld dy, const ld dz)
{
    return sqrt(dx * dx + dy * dy + dz * dz);
}

ld func(const ld x, const ld y, const ld z)
{
    ld sum = 0;
    for (int i = -MAX; i < MAX; i++) {
        for (int j = -MAX; j < MAX; j++) {
            for (int k = -MAX; k < MAX; k++) {
                const ld dx = x - i;
                const ld dy = y - j;
                const ld dz = z - k;
                const ld l = abs(dx, dy, dz);
                if (l != 0) {
                    sum += erfc(G * l) / l;
                }
                const ld L = abs(i, j, k);
                if (L == 0) {
                    continue;
                }
                sum += 4 * PI / L / L * exp(-L * L / 4 / G / G) * cos(x * i + y * j + z * k);
            }
        }
    }
    return sum;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ld> alpha(8);
    vector<ld> beta(8);
    for (int i = 0; i < 8; i++) {
        cin >> alpha[i];
    }
    for (int i = 0; i < 8; i++) {
        cin >> beta[i];
    }
    ld ans = 0;
    for (int i = 0; i < 8; i++) {
        ans += func(X1[i], Y1[i], Z1[i]) * alpha[i];
        ans += func(X2[i], Y2[i], Z2[i]) * beta[i];
    }
    ans += -2 * alpha[0] * sqrt(G * G / PI);  // これ気づかない
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}
0