結果
問題 |
No.1274 楽しい格子点
|
ユーザー |
![]() |
提出日時 | 2020-10-30 22:24:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 860 bytes |
コンパイル時間 | 1,952 ms |
コンパイル使用メモリ | 194,300 KB |
最終ジャッジ日時 | 2025-01-15 17:31:57 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 48 WA * 9 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000005 int main(){ long long A,B; cin>>A>>B; A = abs(A); B = abs(B); if(A>B)swap(A,B); long long G = gcd(A,B); long double ans = 0.0; if(B==0){ ans = 1.0 / pow(2,2); } else if(A==0){ for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ if(i==0&&j%B==0){ ans += 1.0/pow(2+i+j,2+i+j); } } } } else{ if(A==B){ for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ if(i%G==0&&j%G==0 && (i/G + j/G)%2==0){ ans += 1.0 / pow(2+i+j,2+i+j); } } } } else{ for(int i=0;i<=100;i++){ for(int j=0;j<=100;j++){ if(i%G==0&&j%G==0){ ans += 1.0 / pow(2+i+j,2+i+j); } } } } } cout<<fixed<<setprecision(10)<<ans<<endl; return 0; }