Codeforces Round #504 B Pair of Toys


思路:简单数学


#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
typedef long long ll;
ll n,m,ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n >> m;
    ll t = m/2;
    if( n >= m)
    {
        if(m%2 == 0)
            ans = t-1;
        else
            ans = t;
    }
    else
        ans = n - t;

    if(ans > 0)
        cout << ans << endl;
    else
        cout << 0 << endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Whyckck/article/details/81784940
今日推荐