码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces 854 B Maxim Buys an Apartment 思维 水题

时间:2017-10-06 23:15:44      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:最大   技术   log   http   span   using   typedef   分享   方便   

  题目链接: 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

  思考: 水题

Codeforces 854 B Maxim Buys an Apartment 思维 水题

标签:最大   技术   log   http   span   using   typedef   分享   方便   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!