Codeforces 1236A. Stones
注意到两种操作都要消耗中间的石头,并且两种操作每次都会得到 $3$ 个石头
那么显然优先做操作二是最优的,因为操作二只会消耗中间堆的一个石头
如果有剩下再进行操作 $1$ ,那么可以保证总操作次数最大,即答案最大
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=; char ch=getchar();
while(ch<''||ch>'') { if(ch=='-') f=-; ch=getchar(); }
while(ch>=''&&ch<='') { x=(x<<)+(x<<)+(ch^); ch=getchar(); }
return x*f;
}
int main()
{
int T=read();
while(T--)
{
int a=read(),b=read(),c=read(),ans=;
int t=min(b,c/); ans+=t*; b-=t;
t=min(b/,a); ans+=t*;
printf("%d\n",ans);
}
return ;
}
Codeforces 1236A. Stones的更多相关文章
- CodeForces - 1110E-Magic Stones(差分+思维)
Grigory has nn magic stones, conveniently numbered from 11 to nn. The charge of the ii-th stone is e ...
- Codeforces 965 D. Single-use Stones(思维)
Codeforces 965 D. Single-use Stones 题目大意: 有一条河宽度为w,河上有一些石头,给出一组数(编号1~w-1),其中a[i]代表与河一岸距离为i的石头数量.每只青蛙 ...
- 动态规划,而已! CodeForces 433B - Kuriyama Mirai's Stones
Kuriyama Mirai has killed many monsters and got many (namely n) stones. She numbers the stones from ...
- Magic Stones CodeForces - 1110E (思维+差分)
E. Magic Stones time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 【Codeforces 1110E】Magic Stones
Codeforces 1110 E 题意:给定两个数组,从第一个数组开始,每次可以挑选一个数,把它变化成左右两数之和减去原来的数,问是否可以将第一个数组转化成第二个. 思路: 结论:两个数组可以互相转 ...
- codeforces 768E Game of Stones
题目链接:http://codeforces.com/problemset/problem/768/E NIM游戏改版:对于任意一堆,拿掉某个次数最多只能一次. 对于一堆石头数量为$X$.找到一个最小 ...
- Single-use Stones Codeforces - 965D
https://codeforces.com/contest/965/problem/D 太神仙了...比E难啊.. 首先呢,根据题意,可以很容易的建出一个最大流模型 就是每个位置建一条边,容量限制为 ...
- Codeforces 768 E. Game of Stones 博弈DP
E. Game of Stones Sam has been teaching Jon the Game of Stones to sharpen his mind and help him de ...
- 【codeforces 768E】Game of Stones
[题目链接]:http://codeforces.com/contest/768/problem/E [题意] NIM游戏的变种; 要求每一堆石头一次拿了x个之后,下一次就不能一次拿x个了; 问你结果 ...
随机推荐
- 创建express项目(nodejs)
1.下载nodejs安装包 nodejs官网下载最新版本就行,网址:http://nodejs.cn/download/,点击自己适用的系统,自动下载跟电脑操作系统位数符合的安装包, 2.配置环境 最 ...
- python 二进制加法
bin(int(a,2)+int(b,2))[2:]
- Mysql索引查询失效的情况
首先,复习一下索引的创建: 普通的索引的创建: CREATE INDEX (自定义)索引名 ON 数据表(字段); 复合索引的创建: CREATE INDEX (自定义)索引名 ON 数据 ...
- Java-AQS源码详解(细节很多!)
ReentrantLock调用lock()时时序图: addWaiter方法: enq方法:自旋 它维护了一个volatile int state(代表共享资源)和一个FIFO线程等待队列(多线程争用 ...
- JS基础_数组的遍历
遍历:将数组中所有的元素都取出来 1.for循环 var arr = ["1","2","3"]; for(let i=0;i<arr ...
- 微信一键登录(微信OAuth2.0)
1.注册微信开放平台https://open.weixin.qq.com,一定要清楚微信开放平台和微信公众平台是分别独立的,不能共用. 2.登录进入——管理中心,网站应用,创建网站应用.填写申请,企业 ...
- python之scrapy爬取jd和qq招聘信息
1.settings.py文件 # -*- coding: utf-8 -*- # Scrapy settings for jd project # # For simplicity, this fi ...
- Canal——增量同步MySQL数据到ElasticSearch
1.准备 1.1.组件 JDK:1.8版本及以上: ElasticSearch:6.x版本,目前貌似不支持7.x版本: Kibana:6.x版本: Canal.deployer:1 ...
- php curl如何设置自定义请求头和打印请求头信息
$header = [ 'client:h5', 'token:test', ]; curlRequest($url, $params, true, 10, $header); PHP5.1.3版以上 ...
- 【OSS】工具类
package com.aliyun.oss.demo; import com.aliyun.oss.ClientException; import com.aliyun.oss.OSSClient; ...