Codeforces 854 B Maxim Buys an Apartment 思维 水题

  题目链接: https://vjudge.net/problem/CodeForces-854B

  题目描述: 有n个屋子,其中k个屋子是有人住的,如果第i个屋子有人住,那么第i-1个屋子和第i+1个屋子就是特殊的,方便起见这里我们将特殊屋子的数量记为ans。然后给你n和k,让你输出最小的ans和最大的ans

  解题思路: .....特判一下就好了

  代码: 

#include <iostream>
#include <cstdio>
#include <map>
#include <iterator>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;

int main() {
    int n, k;
    cin >> n >> k;
    if( n == k || k == 0 ) {
        cout << 0 << " " << 0 << endl;
    }
    else {
        cout << 1 << " " << min(2*k, n-k) << endl;
    }
    return 0;
}
View Code

  思考: 水题

原文地址:https://www.cnblogs.com/FriskyPuppy/p/7633096.html