(规律)poj - 1218 牛客OI赛制测试赛2 D-星光晚餐
THE DRUNK JAILER
Description A certain * contains a long hall of n cells, each right next to each other. Each cell has a *er in it, and each cell is locked. Input The first line of input contains a single positive integer. This is the number of lines that follow. Each of the following lines contains a single integer between 5 and 100, inclusive, which is the number of cells n. Output For each line, you must print out the number of *ers that escape when the * has n cells. Sample Input
Sample Output
Source |
[Submit] [Go Back] [Status] [Discuss]
链接:https://www.nowcoder.com/acm/contest/185/D
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 131072K,其他语言262144K
64bit IO Format: %lld
题目描述
Johnson和Nancy要在星光下吃晚餐。这是一件很浪漫的事情。
为了增加星光晚餐那浪漫的氛围,他拿出了一个神奇的魔法棒,并且可以按照一定的规则,改变天上星星的亮暗。
Johnson想考考Nancy,在他挥动魔法棒后,会有多少颗星星依旧闪耀在天空。他知道,Nancy一定会一口说出答案。
Nancy当然知道怎么做啦,但她想考考你!
Johnson先将天上n个星星排成一排,起初它们都是暗的。
他告诉他的妹子,他将挥动n次魔法棒,第i次挥动会将编号为i的正整数倍的星星的亮暗反转,即亮的星星转暗,暗的星星转亮。
Johnson想问Nancy,最终会有多少个星星依旧闪亮在天空。
输入描述:
一个整数n,含义请见题目描述。
输出描述:
一个整数ans,即n次操作后会有多少个星星依旧闪亮。
示例1
输入
3
输出
1
示例2
输入
7
输出
2
备注:
对于60%的数据:n≤2×106 对于100%的数据:n≤1018
#include<stdio.h>
#include<math.h>
int main(){
long long n;
scanf("%lld",&n);
printf("%lld",(long long)sqrt(n*1.0));
return 0;
}
上一篇: 蓝桥:字⺟图形