結果
問題 |
No.3168 [Cherry 7th Tune D] Manhole
|
ユーザー |
![]() |
提出日時 | 2025-05-31 19:53:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 194 ms / 2,000 ms |
コード長 | 1,822 bytes |
コンパイル時間 | 1,228 ms |
コンパイル使用メモリ | 41,852 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-05-31 19:53:46 |
合計ジャッジ時間 | 8,198 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:63:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 63 | scanf("%d", &tn); | ~~~~~^~~~~~~~~~~ main.cpp:67:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 67 | scanf("%d%d%d", &a, &b, &c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3168.cc: No.3168 [Cherry 7th Tune D] Manhole - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MOD = 998244353; /* typedef */ template<const int MOD> struct MI { int v; MI(): v() {} MI(int _v): v(_v % MOD) { if (v < 0) v += MOD; } MI(long long _v): v(_v % MOD) { if (v < 0) v += MOD; } explicit operator int() const { return v; } MI operator+(const MI m) const { return MI(v + m.v); } MI operator-(const MI m) const { return MI(v + MOD - m.v); } MI operator-() const { return MI(MOD - v); } MI operator*(const MI m) const { return MI((long long)v * m.v); } MI &operator+=(const MI m) { return (*this = *this + m); } MI &operator-=(const MI m) { return (*this = *this - m); } MI &operator*=(const MI m) { return (*this = *this * m); } bool operator==(const MI m) const { return v == m.v; } bool operator!=(const MI m) const { return v != m.v; } MI pow(int n) const { // a^n % MOD MI pm = 1, a = *this; while (n > 0) { if (n & 1) pm *= a; a *= a; n >>= 1; } return pm; } MI inv() const { return pow(MOD - 2); } MI operator/(const MI m) const { return *this * m.inv(); } MI &operator/=(const MI m) { return (*this = *this / m); } }; using mi = MI<MOD>; /* global variables */ /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int a, b, c; scanf("%d%d%d", &a, &b, &c); // s=PI*r*R -> (s/PI)^2=r^2*R^2 // R=r/cos(th) -> R^2=r^2/cos(th)^2 // Let d=sqrt(a^2+b^2+c^2) -> cos(th)=c/d // -> cos(th)^2=c^2/d^2 // -> R^2=r^2*d^2/c^2=r^2*(a^2+b^2+c^2)/c^2 mi aa = mi(a) * a, bb = mi(b) * b, cc = mi(c) * c; mi rr = (aa + bb+ cc) / cc; printf("%d\n", (int)rr); } return 0; }