cf#345-A - Joysticks-模拟题


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;
	
}  







评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值