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. 2019/10/17 CSP模拟 总结

    T1 补票 Ticket 没什么好说的,不讲了 T2 删数字 Number 很后悔的是其实考场上不仅想出了正解的方程,甚至连优化都想到了,却因为码力不足只打了\(O(n^2)\)暴力,甚至还因为细节挂 ...

  2. 数据交互 axios 的使用

    Axios 是一个基于 promise 的 HTTP 库,可以用在浏览器和 node.js 中. ##Axios npm version build status code coverage npm ...

  3. 《DSP using MATLAB》Problem 8.9

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  4. MFC中使用FLASH相关

    出自http://my.oschina.net/ypimgt/blog/62573 一.准备工作 第一步:下载并安装Adobe Flash Player. 从官方网站(http://get.adobe ...

  5. MySQL模拟Oracle序列使用

    https://www.runoob.com/mysql/mysql-using-sequences.html   一篇笔记开始看 注意:创建序列表时一定要有 主键id自增,否则为只读状态不能修改递增 ...

  6. mybatis使用Example进行条件查询

    参考: https://www.cnblogs.com/zhemeban/p/7183061.html Example类是什么? Example类指定如何构建一个动态的where子句. 表中的每个no ...

  7. Odoo文档管理/知识管理应用实践 - 上传附件

    测试环境: Odoo8.0 Odoo中的文档管理/知识管理可用于保存采购.销售.生产等一系列业务流程中产生的文件.凭证,可关联到具体的每一笔业务操作:也能用于管理公司的合同.资料,创建知识库以分享内部 ...

  8. Django项目:CRM(客户关系管理系统)--67--57PerfectCRM实现admin批量生成上课记录

    #admin.py # ————————01PerfectCRM基本配置ADMIN———————— from django.contrib import admin # Register your m ...

  9. uni-app中不使用scroll-view组件,监听页面滑直底部事件

    最终达到的目标效果 将要用到 监听页面滚动事件:onPageScroll 获取节点信息uni.createSelectorQuery() 标签布局 <template> <view ...

  10. 20191005 - New Beginning

    真·反思 Before 发现$T1$是约瑟夫,$T2$不清楚,$T3$是算法进阶上的$LCIS$ During得&失 做的不错的地方: 多少想了T1的优化(最后没打完). T3的暴力写得很快也 ...