結果

問題 No.3031 曲面の向き付け
コンテスト
ユーザー vjudge1
提出日時 2026-03-23 11:23:13
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,954 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 749 ms
コンパイル使用メモリ 104,760 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-23 11:23:48
合計ジャッジ時間 29,527 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

const int R = 150;

int main() {
    double x0[16], y0[16], z0[16];
    int q[16];
    int alpha[8], beta[8];
    
    for (int i = 0; i < 8; ++i) {
        cin >> alpha[i];
    }
    for (int i = 0; i < 8; ++i) {
        cin >> beta[i];
    }
    
    // Fill alpha ions
    for (int i = 0; i < 8; ++i) {
        int a = i / 4;
        int b = (i % 4) / 2;
        int c = i % 2;
        x0[i] = a / 2.0;
        y0[i] = b / 2.0;
        z0[i] = c / 2.0;
        q[i] = alpha[i];
    }
    
    // Fill beta ions
    int beta_d[8] = {1, 1, 1, 1, 3, 3, 3, 3};
    int beta_e[8] = {1, 1, 3, 3, 1, 1, 3, 3};
    int beta_f[8] = {1, 3, 1, 3, 1, 3, 1, 3};
    for (int i = 0; i < 8; ++i) {
        x0[8 + i] = beta_d[i] / 4.0;
        y0[8 + i] = beta_e[i] / 4.0;
        z0[8 + i] = beta_f[i] / 4.0;
        q[8 + i] = beta[i];
    }
    
    double sum = 0.0;
    long long R_plus_2_sq = (long long)(R + 2) * (R + 2);
    long long R_sq = (long long)R * R;
    
    for (int nx = -R; nx <= R; ++nx) {
        long long nx2 = (long long)nx * nx;
        if (nx2 > R_plus_2_sq) continue;
        for (int ny = -R; ny <= R; ++ny) {
            long long ny2 = (long long)ny * ny;
            if (nx2 + ny2 > R_plus_2_sq) continue;
            for (int nz = -R; nz <= R; ++nz) {
                long long nz2 = (long long)nz * nz;
                if (nx2 + ny2 + nz2 > R_plus_2_sq) continue;
                for (int i = 0; i < 16; ++i) {
                    double x = x0[i] + nx;
                    double y = y0[i] + ny;
                    double z = z0[i] + nz;
                    double r2 = x*x + y*y + z*z;
                    if (r2 < 1e-12) continue;
                    if (r2 > R_sq + 1e-12) continue;
                    sum += q[i] / sqrt(r2);
                }
            }
        }
    }
    
    cout << fixed << setprecision(10) << sum << endl;
    return 0;
}
0