結果
| 問題 |
No.1274 楽しい格子点
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-07 22:54:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 473 bytes |
| コンパイル時間 | 509 ms |
| コンパイル使用メモリ | 72,416 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-22 14:54:54 |
| 合計ジャッジ時間 | 1,821 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 51 WA * 6 |
コンパイルメッセージ
main.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main()
| ^~~~
ソースコード
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
using namespace std;
long A,B;
long gcd(long a,long b){
if(a<0)a=-a;
if(b<0)b=-b;
if(a<b)swap(a,b);
if(a==b||b==0)return a+b;
return gcd(a-2*b,b);
}
main()
{
cin>>A>>B;
long g=gcd(A,B);
double ans=1./4;
if(g)
{
for(int i=3;;i++)
{
long u=2+g*(i-2);
if(u>20)break;
double now=i-1;
for(int j=0;j<u;j++)now/=u;
ans+=now;
}
}
cout<<fixed<<setprecision(16)<<ans<<endl;
}