結果
問題 | No.1274 楽しい格子点 |
ユーザー |
![]() |
提出日時 | 2020-10-30 22:33:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 872 bytes |
コンパイル時間 | 2,020 ms |
コンパイル使用メモリ | 195,012 KB |
最終ジャッジ日時 | 2025-01-15 17:36:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 57 |
ソースコード
#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%B==0&&j%B==0){ ans += 1.0/pow(2+i+j,2+i+j); } } } } else{ if((A/G+B/G)%2==0){ 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; }