[2016-03-08][codeforces][651][A][Joysticks]

Posted 红洋

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[2016-03-08][codeforces][651][A][Joysticks]相关的知识,希望对你有一定的参考价值。

[2016-03-08][codeforces][651][A][Joysticks]
  • 时间:2016-03-08 20:54:05 星期二
  • 题目编号:CF 651 A
  • 题目大意:给两个游戏操纵杆,每个操纵杆分别有a1,a2%的电量,充电器只有一个,每分钟每个操纵杆消耗2%(如果没有充电),增加1%(如果充电),问游戏最长能持续多少时间,充电点允许超过100%,电量为0,游戏结束
  • 输入:a1 a2
  • 输出:最长游戏时间
  • 分析:给电量少的充电,直到有一个没电...

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
#define CLR(x,y) memset((x),(y),sizeof((x)))
#define FOR(x,y,z) for(int (x)=(y);(x)<(z);++(x))
#define FORD(x,y,z) for(int (x)=(y);(x)>=(z);--(x))
#define FOR2(x,y,z) int (x);for((x)=(y);(x)<(z);++(x))
#define FORD2(x,y,z) int (x);for((x)=(y);(x)>=(z);--(x))
int main(){
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        int a1,a2,t = 0;
        scanf("%d%d",&a1,&a2);
        while(a1&&a2){
                if(a1 > a2)     swap(a1,a2);
                if(a1 == a2 && a1 == 1) break;
                ++a1;a2 -= 2;++t;
        }
        printf("%d\n",t);
    return 0;
}  






以上是关于[2016-03-08][codeforces][651][A][Joysticks]的主要内容,如果未能解决你的问题,请参考以下文章

[2016-03-08][651][codeforces][B][Beautiful Paintings]

switch结构2016/03/08

codeforces上怎么看测试数据

如何看codeforces做了多少题

codeforces上怎么看测试数据

codeforces比赛后怎么看题解和答案