2015年NEUACM一月月赛 J: Eliminate zero AC

问题 J: Eliminate zero AC

时间限制: 1 Sec  内存限制: 128 MB

题目描述

Last night,Kid submitted a problem for many times but he got many WA,so he is sad.Out of

sympathy, his coach gave him a very simple problem so that Kid can solve it quickly. The problem

is to select as many numbers as possible range 1 to n so that among these selected number there

are no number can be divided exactly by other number. Can you solve it as quick as Kid?

输入

There are multiple cases.

For each case, there is a integer n(1<=n<=10^9)

输出

For each case,just output the answer.(the most numbers you can select)

样例输入

5

样例输出

3

提示

You can select {2,3,5} or {3,4,5}... but you can’t select {2,3,4,5} because 2|4.

So the answer is 3.

题解:有规律。详见代码。

 1 #include <stdio.h>
 2
 3 int main()
 4 {
 5 #ifdef CDZSC_OFFLINE
 6     freopen("in.txt", "r", stdin);
 7     freopen("out.txt", "w", stdout);
 8 #endif
 9     int n;
10     while(~scanf("%d", &n))
11     {
12         if(n % 2)
13             printf("%d\n", (n >> 1) + 1);
14         else
15             printf("%d\n", n >> 1);
16     }
17     return 0;
18 }

时间: 2024-07-28 22:54:49

2015年NEUACM一月月赛 J: Eliminate zero AC的相关文章

2015年NEUACM一月月赛 J

问题 J: Eliminate zero AC 时间限制: 1 Sec  内存限制: 128 MB提交: 332  解决: 131[提交][状态][讨论版] 题目描述 Last night,Kid submitted a problem for many times but he got many WA,so he is sad.Out of sympathy, his coach gave him a very simple problem so that Kid can solve it q

2015年NEUACM一月月赛

A Money , money 时间限制: 1 Sec  内存限制: 128 MB 提交: 15  解决: 14 [提交][状态][讨论版] 题目描述 Small K seen recently stock market really too violent, so he want to choose some ways to earn money. At every month, he can use three ways to manage his money . For example ,

2015年NEUACM一月月赛 C

问题 C: Sum?Sum! 时间限制: 1 Sec  内存限制: 128 MB提交: 653  解决: 176[提交][状态][讨论版] 题目描述 Kid want to learn math better.Now Kid know how to calculate the sum of 1 to n in a short time.But this time,he is given a much more difficult question——to calculate the sum of

2015年NEUACM一月月赛 B

问题 B: a Simple Problem 时间限制: 1 Sec  内存限制: 128 MB提交: 412  解决: 99[提交][状态][讨论版] 题目描述 Many people think hh is a diaosi, but hh is a very rich man whose nickname is wenzhoutuhao,and he made a lot of money by buying the stock of neusoft. He bought n diamon

CTF-安恒19年一月月赛部分writeup

CTF-安恒19年一月月赛部分writeup MISC1-赢战2019 是一道图片隐写题 linux下可以正常打开图片,首先到binwalk分析一下. 里面有东西,foremost分离一下 有一张二维码,扫一下看看 好吧 不是flag,继续分析图片,在winhex没有发现异常,那么上神器StegSolve分析一下 第一次翻了一遍图层没发现,眼瞎第二次才看见 flag{You_ARE_SOsmart} 提交md5即可 MISC2-memory 内存取证 既然是内存取证直接上volatility 首

zstu19一月月赛 duxing201606的原味鸡树

duxing201606的原味鸡树 题意: 给定一颗有n(n<=1e9)个节点的完全二叉树,1e5次询问,问某个节点有几个子节点. 思路: 自己在月赛上没有思路,问了zfq才知道. 设两个指标,L.R,因为是范围,所以每次L向左孩子一直下去,R向右孩子一直下去,每次下探答案就要加上2的i次,L-R间就是根节点所表示的范围.当n出了L,R区间,退出. #include <algorithm> #include <iterator> #include <iostream&g

2015 HUAS Summer Trainning #5~J

Description We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if s is a regular brackets sequence, then (s) and [s] are regular brackets sequences, and if a and b are regul

dp FOJ 一月月赛C ytaaa

Accept: 57    Submit: 261 Time Limit: 2000 mSec    Memory Limit : 32768 KB  Problem Description Ytaaa作为一名特工执行了无数困难的任务,这一次ytaaa收到命令,需要炸毁敌人的一个工厂,为此ytaaa需要制造一批炸弹以供使用. Ytaaa使用的这种新型炸弹由若干个炸药组成,每个炸药都有它的威力值,而炸弹的威力值为组成这个炸弹的所有炸药的最大威力差的平方,即(max-min)^2,假设一个炸弹有5个

HDU 5245 Joyful (2015年上海大都赛J题,概率)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5245 题意: 给定一个n*m的矩形,由n*m个格子组成,我们可以选k次,每次可以选择的两个格子 这两个格子作为矩形的对角线可以确定一个矩形,这个矩形里的所有小格子都会被覆 盖,求k次后,被覆盖的格子的个数的期望. 分析: 棋盘被覆盖的格子数的期望 = 每个格子被覆盖的概率的和. 每次选择的方案有n*m*n*m种. 格子坐标为(i,j)被覆盖的方案数为: tot = 2*(2*(i*j*(n-i+1)