链接:https://ac.nowcoder.com/acm/contest/view-submission?submissionId=40669755

来源:牛客网

题目描述

As an acmer, Devil Aguin particularly loves numbers. This time, with a sequence consisting of n elements 1∼n initially, Devil Aguin asks you to process the sequence until all the elements in it turn to zero. What you can do in one operation are as following :

1. Select some elements from the sequence arbitrarily.

2. Select a positive integer x arbitrarily.

3. Subtract x from the elements you select.

It is obvious that there are various methods to make elements of the sequence turn to zero. But Devil Aguin demands of you to use the minimum operations. Please tell him how many operations you will use.

输入描述:
The first line contains an integer number T, the number of test cases.

ithith of each next T lines contains one integer n(1≤n≤1001≤n≤100), the number of sequence.

输出描述:
For each test case print a number, the minimum number of operations required.

示例1

输入

2

1

2

输出

1

2

思路

这道题的大概意思是输入t组数据,每组数据有一个数n,代表1~n的数,每次操作可以对任意数减去其中的某个数,直到所有数为0;这道题我们可以简化成将其最大的数n变为0当然我们不能直接减n,通过找规律发现每次减去中间值数是最划算的

代码:

#include<bits/stdc++.h>

using namespace std;

int main()

{

int t;

cin>>t;

while(t--)//对于t组数据

{

int n;

cin>>n;

int s=0;

while(n)//当最大值n为0时跳出来

{

s++;

if(n%2==0)//每次减去中间值

n=n/2;

else

n=(n-1)/2;

}

cout<<s<<endl;

}

}

2019长安大学ACM校赛网络同步赛 Trial of Devil相关推荐

  1. 2019长安大学ACM校赛网络同步赛 L XOR (规律,数位DP)

    链接:https://ac.nowcoder.com/acm/contest/897/L 来源:牛客网 XOR 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言6 ...

  2. 2019长安大学ACM校赛网络同步赛 J Binary Number(组合数学+贪心)

    链接:https://ac.nowcoder.com/acm/contest/897/J 来源:牛客网 Binary Number 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32 ...

  3. 2019长安大学ACM校赛网络同步赛C LaTale (树上DP)

    链接:https://ac.nowcoder.com/acm/contest/897/C 来源:牛客网 LaTale 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 32768K,其他 ...

  4. 2019长安大学ACM校赛网络同步赛 L XOR

    题意 求区间内有多少数x满足x^4x^5x=0 1≤l≤r≤1018. 题解 根据异或的性质可以推到 x^4x=5x -->x^4x=x+4x 即x和4x每一位都不同,即x和(x<< ...

  5. 南昌大学航天杯第二届程序设计竞赛校赛网络同步赛题解

    A,C,I签到题,只搞了8题,还一题是神仙做的,我不会 链接:https://www.nowcoder.com/acm/contest/122/B 来源:牛客网 取石子 时间限制:C/C++ 1秒,其 ...

  6. 南昌大学航天杯第二届程序设计竞赛校赛网络同步赛B 取石子(博弈SG函数模板)

    题目链接:取石子 链接:https://www.nowcoder.com/acm/contest/122/B 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65 ...

  7. 南昌大学航天杯第二届程序设计竞赛校赛网络同步赛 部分题解

    A-ID and password 签到题. #include <iostream> #include <cstdio> #include <bits/stdc++.h& ...

  8. 南昌大学航天杯第二届程序设计竞赛校赛网络同步赛 - 题解

    A - ID and password 题目描述 Users prefer simple passwords that are easy to remember, but such passwords ...

  9. 2016广东工业大学新生杯决赛网络同步赛暨全国新生邀请赛

    2016广东工业大学新生杯决赛网络同步赛暨全国新生邀请赛 Ploblem A :   pigofzhou的巧克力棒 原题链接:http://gdutcode.sinaapp.com/problem.p ...

最新文章

  1. 旷视MegEngine数据加载与处理
  2. C++:运算符重载函数之成员运算符重载函数
  3. java实现 k nn算法_数据挖掘(二)——Knn算法的java实现
  4. 把广告带进虚拟世界实现低成本开发,Anzu.io开始内测报名
  5. SQL Server--用户自定义函数
  6. 爬虫侵入计算机系统,【探讨】利用“爬虫技术”获取数据行为的刑事考量 ——以一起非法获取计算机信息系统数据案为例...
  7. beautifulsoup爬取网页中的表格_PYTHON爬取数据储存到excel
  8. 批量修改Project视图中Prefab的名字
  9. freenas 蜗牛星际_从“白群晖”到“蜗牛星际”,到底哪种NAS方案适合我?
  10. PC电脑控制手机iphone(iOS 11、iOS 12、iOS 13),需越狱
  11. 逆向分析QQ消息自动回复机器人设计
  12. 微信小程序:图片秒加水印制作生成
  13. C#DataGridView使用线程定时循环滚动数据
  14. 第一篇:微信公众平台开发实战Java版之了解微信公众平台基础知识以及资料准备...
  15. [欧美音乐]Tamas Wells -《A Plea en Vendredi》[MP3+FLAC]
  16. 单片机C语言零基础入门05 - 逻辑运算
  17. 官方源、镜像源汇总合集
  18. 基于STM32标准库的MS5837程序移植
  19. 当天期货开户次日就可以交易
  20. 360断网急救箱下载-独立版

热门文章

  1. 怎么把Android手机号码导入,手机联系人怎么导入?通讯录vcf导入安卓手机的方法...
  2. 来 CSDN 实习技术编辑,直面改变世界的技术与人物
  3. std::true_type和std::false_type详解
  4. VINS-FUSION GPS融合坐标转换细节分析
  5. 记录一下,转换树结构数据
  6. Unity3D 开关按钮Toggle (可以做单选按钮)
  7. C语言编写两个函数,分别实现两个整数的最小公倍数和最大公约数
  8. php医疗管理系统(医院患者就诊档案管理系统)源码
  9. 联想微型计算机620S,小巧、精致!联想ideacenter 620s远不止如此
  10. word插入公式,如何输入事例四条件(或者更多)