結果

問題 No.131 マンハッタン距離
ユーザー alorie10alorie10
提出日時 2019-10-05 17:01:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 63,416 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-06 05:42:11
合計ジャッジ時間 1,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,c;
ll gcd(ll n,ll m){
    if(m==0)return n;
    return gcd(m,n%m);
}
int main(void){
    cin>>a>>b>>c;
    if(a+b<c){
        cout<<0<<endl;
        return 0;
    }
    else if(c==0){
        cout<<1<<endl;
        return 0;
    }
    else if(c==a+b){
        cout<<1<<endl;
        return 0;
    }
    else if(a>=c&&b>=c){
        cout<<gcd(c,c)+1LL<<endl;
    }
    else if(b<c&&a<c){
        cout<<gcd(a+b-c,a+b-c)+1LL<<endl;
    }
    else {
        cout<<gcd(a,b)+1LL<<endl;
    }
}
0