結果
問題 |
No.1274 楽しい格子点
|
ユーザー |
![]() |
提出日時 | 2020-10-31 00:09:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 961 bytes |
コンパイル時間 | 1,981 ms |
コンパイル使用メモリ | 193,408 KB |
最終ジャッジ日時 | 2025-01-15 18:12:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 48 WA * 9 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main(){ ll a,b; cin>>a>>b; a=abs(a); b=abs(b); if(a==0 && b==0) cout<<0.25<<endl; else if(a==0){ double ans=0.25; for(int i=1;i<10;i++){ if(2+b*i>10) break; ans+=1.0/(double)pow(2+b*i,2+b*i); } cout<<fixed<<setprecision(10)<<ans<<endl; } else if(b==0){ double ans=0.25; for(int i=1;i<10;i++){ if(2+a*i>10) break; ans+=1.0/(double)pow(a*i+2,a*i+2); } cout<<fixed<<setprecision(10)<<ans<<endl; } else{ ll g=gcd(a,b); double ans=0; if(g>100){ cout<<0.25<<endl; return 0; } for(int i=0;i<10;i++){ for(int j=0;j<10;j++){ if(2+g*(i+j)>10) continue; ans+=1.0/(double)pow(2+g*(i+j),2+g*(i+j)); } } cout<<fixed<<setprecision(10)<<ans<<endl; } return 0; }