結果

問題 No.1274 楽しい格子点
ユーザー 👑 emthrmemthrm
提出日時 2020-10-30 22:45:07
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 802 ms / 2,000 ms
コード長 1,369 bytes
コンパイル時間 2,178 ms
使用メモリ 8,368 KB
最終ジャッジ日時 2023-02-22 17:11:41
合計ジャッジ時間 34,294 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 361 ms
6,284 KB
testcase_01 AC 720 ms
6,260 KB
testcase_02 AC 219 ms
6,324 KB
testcase_03 AC 719 ms
6,248 KB
testcase_04 AC 217 ms
6,272 KB
testcase_05 AC 433 ms
6,184 KB
testcase_06 AC 217 ms
6,252 KB
testcase_07 AC 676 ms
6,196 KB
testcase_08 AC 723 ms
6,252 KB
testcase_09 AC 434 ms
6,252 KB
testcase_10 AC 432 ms
6,196 KB
testcase_11 AC 217 ms
6,196 KB
testcase_12 AC 432 ms
6,280 KB
testcase_13 AC 432 ms
6,264 KB
testcase_14 AC 217 ms
6,208 KB
testcase_15 AC 676 ms
6,248 KB
testcase_16 AC 432 ms
6,288 KB
testcase_17 AC 433 ms
6,256 KB
testcase_18 AC 431 ms
6,276 KB
testcase_19 AC 432 ms
6,256 KB
testcase_20 AC 432 ms
6,176 KB
testcase_21 AC 674 ms
6,248 KB
testcase_22 AC 363 ms
6,248 KB
testcase_23 AC 728 ms
6,200 KB
testcase_24 AC 364 ms
6,248 KB
testcase_25 AC 364 ms
6,248 KB
testcase_26 AC 364 ms
6,252 KB
testcase_27 AC 363 ms
6,180 KB
testcase_28 AC 729 ms
6,272 KB
testcase_29 AC 361 ms
6,260 KB
testcase_30 AC 725 ms
6,196 KB
testcase_31 AC 360 ms
7,656 KB
testcase_32 AC 720 ms
7,672 KB
testcase_33 AC 722 ms
7,652 KB
testcase_34 AC 719 ms
7,660 KB
testcase_35 AC 723 ms
7,652 KB
testcase_36 AC 725 ms
8,224 KB
testcase_37 AC 721 ms
8,316 KB
testcase_38 AC 720 ms
8,368 KB
testcase_39 AC 362 ms
7,660 KB
testcase_40 AC 723 ms
8,220 KB
testcase_41 AC 722 ms
8,300 KB
testcase_42 AC 361 ms
7,584 KB
testcase_43 AC 361 ms
8,216 KB
testcase_44 AC 718 ms
7,596 KB
testcase_45 AC 720 ms
7,580 KB
testcase_46 AC 719 ms
8,236 KB
testcase_47 AC 360 ms
8,312 KB
testcase_48 AC 360 ms
7,680 KB
testcase_49 AC 676 ms
8,328 KB
testcase_50 AC 722 ms
8,240 KB
testcase_51 AC 361 ms
7,672 KB
testcase_52 AC 2 ms
8,252 KB
testcase_53 AC 802 ms
8,240 KB
testcase_54 AC 716 ms
7,668 KB
testcase_55 AC 433 ms
7,652 KB
testcase_56 AC 218 ms
8,324 KB
testcase_57 AC 733 ms
8,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll a, b; cin >> a >> b;
  if (a == 0 && b == 0) {
    cout << 0.25 << '\n';
    return 0;
  }
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  ll g = gcd(a, b);
  long double ans = 0;
  if ((a / g + b / g) % 2 == 0) {
    REP(x, 1000) for (int y = x & 1; y < 1000; y += 2) ans += 1 / powl(1.0L * g * (x + y) + 2, 1.0L * g * (x + y) + 2);
  } else {
    REP(x, 1000) REP(y, 1000) ans += 1 / powl(1.0L * g * (x + y) + 2, 1.0L * g * (x + y) + 2);
  }
  cout << ans << '\n';
  return 0;
}
0