結果
問題 | No.131 マンハッタン距離 |
ユーザー |
![]() |
提出日時 | 2019-10-05 17:04:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 572 bytes |
コンパイル時間 | 612 ms |
コンパイル使用メモリ | 63,488 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-06 05:50:48 |
合計ジャッジ時間 | 1,397 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#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(min(a,b),min(a,b))+1LL<<endl; } }