結果

問題 No.1274 楽しい格子点
ユーザー chocorusk
提出日時 2020-10-30 22:37:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 124,452 KB
最終ジャッジ日時 2025-01-15 17:41:05
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
using ll=long long;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main()
{
    ll a, b; cin>>a>>b;
    if(a==0 && b==0){
        cout<<0.25<<endl;
        return 0;
    }
    ll d=gcd(a, -b);
    a/=d;
    b/=d;
    double ans=0;
    int i=0;
    for(double x=1; x<=50; x+=d, i++){
        int j=0;
        for(double y=1; y<=50; y+=d, j++){
            if((i+j)%2!=0 && a%2!=0 && b%2!=0) continue;
            ans+=pow(x+y, -(x+y));
        }
    }
    printf("%.7lf\n", ans);
    return 0;
}
0