Dexter is tired of Dee Dee. So he decided to keep Dee Dee busy in a game. The game he planned for her is quite easy to play but not easy to win at least not for Dee Dee. But Dexter does not have time to spend on this silly task, so he wants your help. There will be a button, when it will be pushed a random number N will be chosen by computer. Then on screen there will be numbers from 1 to N. Dee Dee can choose any number of numbers from the numbers on the screen, and then she will command computer to subtract a positive number chosen by her (not necessarily on screen) from the selected numbers. Her objective will be to make all the numbers 0. For example if N = 3, then on screen there will be 3 numbers on screen: 1, 2, 3. Say she now selects 1 and 2. Commands to subtract 1, then the numbers on the screen will be: 0, 1, 3. Then she selects 1 and 3 and commands to subtract 1. Now the numbers are 0, 0, 2. Now she subtracts 2 from 2 and all the numbers become 0. Dexter is not so dumb to understand that this can be done very easily, so to make a twist he will give a limit L for each N and surely L will be as minimum as possible so that it is still possible to win within L moves. But Dexter does not have time to think how to determine L for each N, so he asks you to write a code which will take N as input and give L as output. Input Input consists of several lines each with N such that 1 ≤ N ≤ 1, 000, 000, 000. Input will be terminated by end of file. Output For each N output L in separate lines. Sample Input 1 2 3 Sample Output 1 2 2

https://odzkskevi.qnssl.com/33af24c925ae62df4c094b22a2ba7e37?v=1507989644

【题解】

这个题还真是蛮巧的。通过尽可能减多的一块,把剩下的转换成已有的,显然取1/2,虽然代码好写了点(捂脸)

水题不能算颓......水题!Oier的事,能算颓嘛(捂脸)?

 #include<iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define abs(a) (((a) < 0) ? (-1 * (a)) : (a))
inline void swap(int &a, int &b)
{
int tmp = a;a = b;b = tmp;
}
inline void read(long long &x)
{
x = ;char ch = getchar(), c = ch;
while(ch < '' || ch > '')c = ch, ch = getchar();
while(ch <= '' && ch >= '')x = x * + ch - '', ch = getchar();
if(c == '-')x = -x;
} const int INF = 0x3f3f3f3f; int dfs(long long now)
{
if(now == )return ;
else return dfs(now/) + ;
} long long n; int main()
{
while(scanf("%lld", &n) != EOF)
{
printf("%d\n", dfs(n));
}
return ;
}

Uva113384

Uva11384 Help is needed for Dexter的更多相关文章

  1. uva------Help is needed for Dexter(11384)

    Problem H Help is needed for Dexter Time Limit: 3 Second Dexter is tired of Dee Dee. So he decided t ...

  2. UVA 11384 Help is needed for Dexter(问题转化 递归)

    Help is needed for Dexter Time Limit: 3 Second Dexter is tired of Dee Dee. So he decided to keep Dee ...

  3. 【巧妙算法系列】【UVA 11384】 Help is needed for Dexter 正整数序列

    Help is needed for Dexter Time Limit: 3 Second Dexter is tired of Dee Dee. So he decided to keep Dee ...

  4. UVA.11384 Help is needed for Dexter (思维题)

    UVA.11384 Help is needed for Dexter (思维题) 题意分析 同样水题一道,这回思路对了. 给出数字n,面对一个1,2,3,4--n的数字序列,你可以对他们的部分或者全 ...

  5. UVA 11384 Help is needed for Dexter(递归)

    题目链接:https://vjudge.net/problem/UVA-11384 这道题要分析得透: 如果我们手模的话,会发现:如果先将大于$\frac{n}{2}$的数都减去$\frac{n}{2 ...

  6. UVa 11384 Help is needed for Dexter

    分析题目以后得出,对于一个连续等差递增的序列,例如1,2,3,4,5,6,每次选择其中后一半,减去能减的最大数,则是最优操作. 上述序列经过一次操作后变为1,2,3,0,1,2,此时可抛弃后一半(已经 ...

  7. UVa 11384 Help is needed for Dexter 正整数序列

    给定一个正整数 n ,你的任务使用最少的操作次数把序列 1, 2, 3, -- , n 中的所有数都变成 0 .每次操作可以从序列中选择一个或者多个数,同时减去一个相同的正整数.比如,1, 2, 3 ...

  8. Help is needed for Dexter UVA - 11384(二分)

    本来抱着wa一发的心态写写,没想到过了. 算是一种二分吧. 也就是说,减数取太大和太小都不好,怎样是最好的呢?当然是,每次减去一个数之后新形成的序列和前面的序一样是最好的 这样的话,本来想写个二分,但 ...

  9. UVa 11384 - Help is needed for Dexter 分析, 树状数组 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

随机推荐

  1. PHP函数高级(二)

    PHP函数基础:https://www.cnblogs.com/lxwphp/p/9867840.html   1.函数分类: 定义:完成某些功能的代码段 系统函数:字符串,数组,数字,日期时间 自定 ...

  2. System.Web.Mvc.ValueProviderResult.cs

    ylbtech-System.Web.Mvc.ValueProviderResult.cs 1.程序集 System.Web.Mvc, Version=5.2.3.0, Culture=neutral ...

  3. IDEA如何像Eclipse打开多个项目?

    简述: 不能采用open方式,得采用 import module方式 (多个项目,可以不再同一个根目录下,真正的类似eclipse方式打开多个项目) 具体操作步骤: 1.选择一个maven项目,右键选 ...

  4. 组件:基础的基础组件(Component,Portlet)

    <!DOCTYPE html> <html lang="zh"> <head> <title></title> < ...

  5. Ubuntu+Ruby+MySQL+Nginx+Redmine部署记录

    (2019年2月19日注:这篇文章原先发在自己github那边的博客,时间是2016年7月26日) 周五的时候老大布置了一个任务下来,要部署一个Redmine用于研发部,同时升级工作室的Redmine ...

  6. day 46 Javascript学习

    Javascript学习   JavaScript概述 ECMAScript和JavaScript的关系 1996年11月,JavaScript的创造者--Netscape公司,决定将JavaScri ...

  7. springboot自己实现mysql主从数据切换机制

    在很多公司都是实现了数据的读写分离,所谓的读写分离,就是写的时候从主库 ,然后从库就会从主库中复制过去,这样就会形成了数据的读写分离,然而在很多场景是适用的,那么我们怎么做呢,可以利用aop 加注解的 ...

  8. Nginx部署vue项目的配置

    . 官网下载 http://nginx.org/en/download.html 选择stable version nginx/Windows-1.14.1 pgp . 解压 然后配置环境变量,如果环 ...

  9. iotop实时监控磁盘io

    介绍 Linux下的IO统计工具如iostat, nmon等大多数是只能统计到per设备的读写情况, 如果你想知道每个进程是如何使用IO的就比较麻烦. iotop 是一个用来监视磁盘 I/O 使用状况 ...

  10. Gartner首推机密计算:阿里云名列其中

    近日,全球信息技术研究机构Gartner发布了2019年云安全技术成熟度曲线报告(Gartner, Hype Cycle for Cloud Security, 2019, Jay Heiser, S ...