結果

問題 No.1274 楽しい格子点
ユーザー 🍮かんプリン
提出日時 2020-10-30 22:44:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 951 bytes
コンパイル時間 1,661 ms
コンパイル使用メモリ 168,236 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-22 02:18:40
合計ジャッジ時間 9,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other AC * 1 RE * 56
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:43:15: warning: division by zero [-Wdiv-by-zero]
   43 |     cout << 1 / 0 << endl;
      |             ~~^~~

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.10.30 22:15:35
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    ll a,b;cin >> a >> b;
    if (a == 0 && b == 0) {
        cout << 0.25 << endl;
        return 0;
    }
    else if (a == 0 || b == 0) {
        a = a+b;
        a = abs(a);
        double ans = 0;
        for (int i = 0; i <= 1000000/a; i++) {
            ans += 1.0/pow(i*a+2,i*a+2);
        }
        printf("%.10f\n",ans);
        return 1;
    }
    a = abs(a);
    b = abs(b);
    ll g = __gcd(a,b);
    double ans = 0;
    a/=g;
    b/=g;
    if ((a & 1) == (b & 1)) {
        for (int i = 0; i <= 1000000/g; i+=2) {
            ans += 1.0/pow(i*g+2,i*g+2)*(i+1);
        }
    }
    else {
        for (int i = 0; i <= 1000000/g; i++) {
            ans += 1.0/pow(i*g+2,i*g+2)*(i+1);
        }
    }
    cout << 1 / 0 << endl;
    printf("%.10f\n",ans);
    return 0;
}
0