結果

問題 No.966 引き算をして門松列(その1)
ユーザー alexara1123alexara1123
提出日時 2020-01-13 20:39:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,974 bytes
コンパイル時間 1,019 ms
コンパイル使用メモリ 100,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 13:09:48
合計ジャッジ時間 1,608 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

ll a[101010];
ll solve()
{
    ll t;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        if(b > a && b > c){
            cout << 0 << endl;
            continue;
        }else if(b < a && b < c){
            cout << 0 << endl;
            continue;
        }

        if(b == 1){
            cout << -1 << endl;
            continue;
        }else if(a == 1 && b == 2 && c == 3){
            cout << -1 << endl;
            continue;
        }else if(a == 3 && b == 2 && c == 1){
            cout << -1 << endl;
            continue;
        }else if(max(a,max(b,c)) <= 2){
            cout << -1 << endl;
            continue;
        }
        
        if (a > b && b > c)
        {
            cout << min(a - b + 1, b - c + 1) << endl;
        }
        else if (a < b && b < c)
        {
            cout << min(c - b + 1, b - a + 1) << endl;
        }else if(a == b && b == c){
            cout << 3 << endl;
        }

    }

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}
0