結果
| 問題 |
No.1274 楽しい格子点
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2020-10-30 22:04:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,123 bytes |
| コンパイル時間 | 1,638 ms |
| コンパイル使用メモリ | 169,608 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-22 00:40:27 |
| 合計ジャッジ時間 | 3,166 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 48 WA * 9 |
ソースコード
#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 (B == 0){
swap(A, B);
}
if (A == 0){
double ans = 0;
for (int i = 1; i <= 100; i++){
if ((i - 1) % g == 0){
ans += p(1 + i);
}
}
cout << ans << endl;
} else 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;
}
}
SSRS