結果
| 問題 |
No.1274 楽しい格子点
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2020-12-13 19:10:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 570 bytes |
| コンパイル時間 | 2,405 ms |
| コンパイル使用メモリ | 193,536 KB |
| 最終ジャッジ日時 | 2025-01-16 23:47:35 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 57 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define rep(i,n) for(int i=0; i<(n); i++)
LL GCD(LL a,LL b){ return b?GCD(b,a%b):a; }
double F(double x){ return pow(x,-x); }
int main(){
LL A,B; cin>>A>>B;
A=abs(A); B=abs(B);
double ans=0.;
if(A!=0 && B!=0){
LL G=GCD(A,B); A/=G; B/=G;
if(A%2==1 && B%2==1){rep(x,20)rep(y,20)if((x+y)%2==0)ans+=F(x*G+y*G+2);}
else rep(x,20)rep(y,20)ans+=F(x*G+y*G+2);
}
else if(A==0 && B==0) ans=0.25;
else rep(x,20)rep(y,20)ans+=F((x+y)*(A+B)+2);
cout<<fixed<<setprecision(10)<<ans<<endl;
return 0;
}
Nachia