列表

详情


NC14626. Liao Han

描述

Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e18) guys standing in a row, because the boys had some strange character,The first time to Liao them will not be successful, but the second time will be successful; third times to Liao them  will not be successful, but the fourth time will be successful;....... By analogy (toxic psycho)

So the little koala burst odd thought of a fancy up method. The N is the sum of handsome boys, and labeled from 1 to N, starting from the first guy, whose number is 1, she will Liao all the boys whose number is Multiple of 1, then number 2 and all the boys whose number is Multiple of 2(toxic method)

Later, little Kola found that some handsome guys did not get her Liao, she asked the smart you to help her look for how many handsome guys did not successfully be Liaoed?


输入描述

Multiple groups of Case. (no more than 10000 groups)
Each group of data is 1 lines, with an integer N per line.
The N is 0 at the end of the input.

输出描述

Each group of Output1 rows, a number of 1 lines representing the number of boys with no Liao to the group of data.

示例1

输入:

1
2
3
4
0

输出:

1
1
1
2

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++14(g++5.4) 解法, 执行用时: 18ms, 内存消耗: 508K, 提交时间: 2020-08-06 15:16:24

#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    while(cin>>n){ 
        if(n==0){
            break;
        }
        ll res=sqrt((long double)n);
        cout<<res<<endl;
    }
}

C++11(clang++ 3.9) 解法, 执行用时: 38ms, 内存消耗: 332K, 提交时间: 2020-03-12 13:57:12

#include<bits/stdc++.h>
using namespace std;
long double n;
int main()
{
	while(1)
	{
		cin>>n;
		if(n==0) break;
		cout<<(long long)sqrt(n)<<endl;
	}
	return 0;
}

上一题