結果
問題 |
No.1274 楽しい格子点
|
ユーザー |
![]() |
提出日時 | 2020-10-30 22:02:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 917 bytes |
コンパイル時間 | 1,413 ms |
コンパイル使用メモリ | 167,116 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-22 00:39:16 |
合計ジャッジ時間 | 2,885 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 50 WA * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; double p(int x){ double ans = 1; for (int i = 0; i < x; i++){ ans /= x; } return ans; } int main(){ cout << fixed << setprecision(10); long long A, B; cin >> A >> B; if (A == 0 && B == 0){ cout << p(2) << endl; return 0; } A = abs(A); B = abs(B); long long g = __gcd(A, B); A /= g; B /= g; if (A % 2 == 1 && B % 2 == 1){ double ans = 0; for (int i = 1; i <= 100; i++){ for (int j = 1; j <= 100; j++){ if ((i - 1) % g == 0 && (j - 1) % g == 0){ if (abs(i - j) % g == 0){ ans += p(i + j); } } } } cout << ans << endl; } else { double ans = 0; for (int i = 1; i <= 100; i++){ for (int j = 1; j <= 100; j++){ if ((i - 1) % g == 0 && (j - 1) % g == 0){ ans += p(i + j); } } } cout << ans << endl; } }