题目链接:点击打开链接

3个数为一组,找最大的一个数让它降低,则显然是有解的,分类讨论一下就可以

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
int n, k;
int a[4];
vector<pair<int,int> >ans;
int maxpos(){
int pos = 0;
for(int i = 1; i < 4; i++)
if(a[pos]<a[i])pos = i;
return pos;
}
void chu(int pos){
a[pos] >>= 1; a[(pos+1)%4] >>= 1;
ans.push_back(pair<int,int>(0, pos));
}
void ADD(int pos){
a[pos] ++; a[(pos+1)%4] ++;
ans.push_back(pair<int,int>(1, pos));
}
int main(){
while(cin>>a[0]>>a[1]>>a[2]>>a[3]){
ans.clear();
int pos, siz = 0;
while(1){
pos = maxpos();
if(a[pos]==1)return true;
int l = pos-1; if(l<0)l = 3;
int r = pos+1; if(r>3)r = 0;
if(a[pos]&1){
if(a[l]&1)
{
ADD(l);
chu(l);
}
else if(a[r]&1)
{
ADD(pos);
chu(pos);
}
else {
ADD(pos);
chu(l);
}
}
else {
if((a[l]&1)==0)
{
chu(l);
}
else if((a[r]&1)==0)
{
chu(pos);
}
else {
ADD(l); ADD(pos);
chu(l);
}
}
}
for(int i = 0; i < ans.size(); i++)
printf("%c%d\n", ans[i].first?'+':'/', ans[i].second+1);
}
return 0;
}

CodeForces 42C Safe cracking 规律题的更多相关文章

  1. Codeforces 480B Long Jumps 规律题

    题目链接:点击打开链接 题意: 输出n l x y 有一根直尺长度为l 上面有n个刻度. 以下n个数字是距离开头的长度(保证第一个数字是0,最后一个数字是l) 要使得 直尺中存在某2个刻度的距离为x ...

  2. Codeforces - 规律题 [占坑]

    发现自己容易被卡水题,需要强行苟一下规律题 CF上并没有对应的tag,所以本题集大部分对应百毒搜索按顺序刷 本题集侧重于找规律的过程(不然做这些垃圾题有什么用) Codeforces - 1008C ...

  3. LightOJ1010---Knights in Chessboard (规律题)

    Given an m x n chessboard where you want to place chess knights. You have to find the number of maxi ...

  4. ACM_送气球(规律题)

    送气球 Time Limit: 2000/1000ms (Java/Others) Problem Description: 为了奖励近段时间辛苦刷题的ACMer,会长决定给正在机房刷题的他们送气球. ...

  5. hdoj--1005--Number Sequence(规律题)

    Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  7. You Are Given a Decimal String... CodeForces - 1202B [简单dp][补题]

    补一下codeforces前天教育场的题.当时只A了一道题. 大致题意: 定义一个x - y - counter :是一个加法计数器.初始值为0,之后可以任意选择+x或者+y而我们由每次累加结果的最后 ...

  8. codeforces 1165F1/F2 二分好题

    Codeforces 1165F1/F2 二分好题 传送门:https://codeforces.com/contest/1165/problem/F2 题意: 有n种物品,你对于第i个物品,你需要买 ...

  9. Codeforces 959E. Mahmoud and Ehab and the xor-MST 思路:找规律题,时间复杂度O(log(n))

    题目: 解题思路 这题就是0,1,2...n-1总共n个数字形成的最小生成树. 我们可以发现,一个数字k与比它小的数字形成的异或值,一定可以取到k与所有正整数形成的异或值的最小值. 要计算n个数字的情 ...

随机推荐

  1. Android 识别身份证号码(图片识别)

    概述 Android 身份证号码识别 (本地,在线,实时),网络识别用的别人的接口,不保障什么时候就用不了了,本地识别基于tess_two,位置对的话识别准确率达到90%以上. 详细 代码下载:htt ...

  2. 简单hello world

    第一步配置路由: 打开app/http/route.php文件,输入:Route::get('/home', 'HomeController@index'); 第二步配置控制器: 控制文件可以手动添加 ...

  3. Android屏幕计量单位详解

    1.px (pixels)(像素):是屏幕的物理像素点,与密度相关,密度大了,单位面积上的px会比较多.通常不推荐使用这个. 2.dip或dp(与密度无关的像素):一个基于density的抽象单位,这 ...

  4. Axure 蚂蚁设计团队组件库 让交互稿美美"搭"

    Github资源:https://github.com/ant-design/ant-design-pro English | 简体中文 技术实践篇 https://pro.ant.design/do ...

  5. EF Code First 注意事项

    1.异常“实体类型不存在于上下文中” Context类中不包含该实体类型的DbSet,有可能关联关系没有正确设置

  6. 趣味SQL——创建指定的数据类型

    原创作品,出自 "深蓝的blog" 博客,深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/46908843 趣味 ...

  7. Windows路由表配置:双网卡同时上内外网

    管理员模式CMD 路由表解释 route print -4 删除默认设置 route delete 0.0.0.0 外网路由,全走无线,192.168.0.1为无线网关 route add 0.0.0 ...

  8. hive partition 分区使用

    一.背景 1.在Hive Select查询中一般会扫描整个表内容,会消耗很多时间做没必要的工作.有时候只需要扫描表中关心的一部分数据,因此建表时引入了partition概念. 2.分区表指的是在创建表 ...

  9. elipse快捷键大全 elipse快捷键详解

    1. ctrl+shift+r:打开资源 这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的前几个字母,比如applic*.xm ...

  10. 让HttpClient不要打印巨多的日志

    让HttpClient不要打印巨多的日志 log4j.logger.org.apache.commons.httpclient=DEBUG 參考http://hc.apache.org/httpcli ...