您的位置:首页 > 其它

cf#345-A - Joysticks-模拟题

2016-03-07 22:08 302 查看
http://codeforces.com/contest/651/problem/A

题意,初始两个操控杆电量a1,a2

每分钟可以给其中一个充电。充电的电量+1,另一个则电量-2

电量可以超过100

任何一个秆电量=0,游戏结束

问你最多可以玩多少分钟

。。。直接模拟,。题意没读好。。。样例 1 1 的答案应该是0,我以为是1。。。。。

还有 2 1 我以为不可以。。其实是可以给第二个充电 变成 0 2

WA6


#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

const double pi=acos(-1.0);
double eps=0.000001;
__int64 max(__int64 a,__int64 b)
{return a>b?a:b;}
int main()
{

__int64 n,m;
scanf("%I64d%I64d",&n,&m);
__int64 what=0;
while(1)
{
while (n>2)
{

what++;
n-=2;
m++;
}
while (m>2)
{

what++;
m-=2;
n++;
}
if (n<=2&&m<=2) break;
}
if (n==2&&m==1) what++;
if (n==2&&m==2) what++;
if (n==1&&m==2) what++;

printf("%I64d\n", what);

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: