Uva11384 Help is needed for Dexter
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的更多相关文章
- 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 ...
 - 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 ...
 - 【巧妙算法系列】【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 ...
 - UVA.11384 Help is needed for Dexter (思维题)
		
UVA.11384 Help is needed for Dexter (思维题) 题意分析 同样水题一道,这回思路对了. 给出数字n,面对一个1,2,3,4--n的数字序列,你可以对他们的部分或者全 ...
 - UVA 11384 Help is needed for Dexter(递归)
		
题目链接:https://vjudge.net/problem/UVA-11384 这道题要分析得透: 如果我们手模的话,会发现:如果先将大于$\frac{n}{2}$的数都减去$\frac{n}{2 ...
 - UVa 11384 Help is needed for Dexter
		
分析题目以后得出,对于一个连续等差递增的序列,例如1,2,3,4,5,6,每次选择其中后一半,减去能减的最大数,则是最优操作. 上述序列经过一次操作后变为1,2,3,0,1,2,此时可抛弃后一半(已经 ...
 - UVa 11384 Help is needed for Dexter 正整数序列
		
给定一个正整数 n ,你的任务使用最少的操作次数把序列 1, 2, 3, -- , n 中的所有数都变成 0 .每次操作可以从序列中选择一个或者多个数,同时减去一个相同的正整数.比如,1, 2, 3 ...
 - Help is needed for Dexter UVA - 11384(二分)
		
本来抱着wa一发的心态写写,没想到过了. 算是一种二分吧. 也就是说,减数取太大和太小都不好,怎样是最好的呢?当然是,每次减去一个数之后新形成的序列和前面的序一样是最好的 这样的话,本来想写个二分,但 ...
 - UVa 11384 - Help is needed for Dexter 分析, 树状数组 难度: 0
		
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
 
随机推荐
- Joomla - K2组件(文章管理扩展)
			
一.下载 K2 进入 https://getk2.org/ ,点击DOWNLOAD K2 下载K2 下载完毕得到一个安装包 二.安装 K2 进入看后台,点击顶栏主菜单 扩展管理 -> 扩展安装 ...
 - hibernate hql语句 注意事项
			
现在有实体类 Student 和User . public class Student{ private String id; private Sting classRoom; private Use ...
 - MFC安装与部署(程序打包)
			
(发现csdn传照片实在是太麻烦, 不能够直接拖拽进来;所以我直接使用云笔记生成一张图片 直接完成!) (懒癌晚期-)
 - [51nod-1364]最大字典序排列
			
[51nod-1364]最大字典序排列 Online Judge:51nod-1364 Label:线段树,树状数组,二分 题目描述 题解: 根据题意很容易想到60%数据的\(O(N^2logN)\) ...
 - 关于vue项目报错:this relative module was not found
			
VScode编辑器增加了一行代码import func from './vue-temp/vue-editor-bridge'; 删除即可
 - 主从复制系列B
			
从服务器靠中继日志来接收从主服务器上传回来的日志.并依靠状态文件来记录已经从主服务器接收了哪些日志,已经恢复了哪些日志. 中继日志与二进制日志的格式相同,并且可以用mysqlbinlog读取.SQL线 ...
 - LUOGU P1903 [国家集训队]数颜色 / 维护队列
			
传送门 解题思路 带修莫队,第一次写,其实和普通莫队差不多,就是多了个时间轴,块分n^(2/3)最优,时间复杂度O(n^(5/3)). #include<iostream> #includ ...
 - Java程序员面试题收集(4)
			
Java面试题和答案JAVA相关基础知识1.面向对象的特征有哪些方面 1.抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题 ...
 - LINUX查询登录主机的用户工具:w 、who 、users
			
w.who和users工具,是查询已登录当前主机的用户:另外finger -s 也同样能查询:侧重点不一样:请自己对比着看:毕竟简单,这里只是介绍 : [beinan@localhost ~]$ w ...
 - BZOJ1491:1491: [NOI2007]社交网络
			
1491: [NOI2007]社交网络 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 2204 Solved: 1175[Submit][Status ...