【CodeForces 651A】Joysticks 模拟
题意:给定a,b,每个单位时间可以将a,b中一台加1,一台减2,求最久可以支持多久。
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=256;
int n1,n2;
int cnt;
int main(void)
{
scanf("%d%d",&n1,&n2);
while (n1>0&&n2>0)
{
if (n1<n2) swap(n1,n2);
n1-=2,n2++;
if (n1>=0&&n2>=0) cnt++;
}
printf("%d\n",cnt);
return 0;
}
【CodeForces 651A】Joysticks 模拟的更多相关文章
- CodeForces 651A Joysticks 贪心
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- codeforces 651A Joysticks
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces 651A Joysticks【贪心】
题意: 两根操纵杆,每分钟操纵杆消耗电量2%,每分钟又可以给一个操纵杆充电1%(电量可以超过100%),当任何一个操纵杆电量降到0时,游戏停止.问最长游戏时间. 分析: 贪心,每次选择电量剩余最少的充 ...
- codeforces 651A A. Joysticks (模拟)
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces 389B(十字模拟)
Fox and Cross Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submi ...
- codeforces 591B Rebranding (模拟)
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...
- Codeforces 626B Cards(模拟+规律)
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...
- Codeforces 631C. Report 模拟
C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...
- Codeforces 679B. Barnicle 模拟
B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...
随机推荐
- SqlSever基础 两个条件 group by 分组显示
镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...
- Linux网络统计工具/命令
我在Linux(基于CentOS 或者 Debian 的发行版)中该如何查看当前网络端口吞吐量的统计信息?在Linux操作系统中如何查看当前内核snmp计数器以及网络端口的统计信息? 你可以使用以下任 ...
- 我的android学习经历18
今天主要学了几个android控件和使用两个适配器 ListView DatePicker和TimePicker GridView 适配器:SimpleAdapter和ArrayAdapter 都是常 ...
- JAVA的文件创建
package com.xia; import java.io.*; public class test2 { public static void main(String[] args) { //输 ...
- css选择器选择顺序是从右往左的,为什么?
https://segmentfault.com/q/1010000000713509 为什么 CSS 选择器解析的时候是从右往左? CSS 的后代选择器本身就是一种在标准里面不那么推荐的方式. 首先 ...
- 关于JDK的配置
① 安装官网下载的相应JDK安装包. 现在官网主推JDK8,JDK7以及更老的版本需要注册才能提供下载链接. ② 比如个人下载的jdk7-xxx.exe,安装路径为C:\Program Files\J ...
- Phonegap项目中禁用WebViewBounce
UIWebView是iOS SDK中一个最常用的控件,在PhoneGap中,默认也是使用UIWebView作为默认视图显示我们的HTML应用的. 在使用PhoneGap的项目中,默认WebView ...
- shell 随机从文件中抽取若干行
shuf -n5 main.txt sort -R main.txt | head -5 awk -vN=5 -vC="`wc -l file`" 'BEGIN{srand();w ...
- jdk安装环境变量设置
设置JAVA_HOME,点击新建,变量名:JAVA_HOME,变量值:D:\java\jdk1.7.0,即刚才jdk安装的路径. 设置CLASSPATH属性,变量名:CLASSPATH,变量值:. ...
- WinForm 弹框确认后执行
if (MessageBox.Show("你确定要退出程序吗?", "确认", MessageBoxButtons.OKCancel, MessageBoxIc ...