【2017广西邀请赛】hdu 6182 A Math Problem
2017-09-06 08:13
381 查看
Problem Description
You are given a positive integer n, please count how many positive integers k satisfy kk≤n.
Input
There are no more than 50 test cases.
Each case only contains a positivse integer n in a line.
1≤n≤1018
Output
For each test case, output an integer indicates the number of positive integers k satisfy kk≤n in
a line.
Sample Input
1
4
Sample Output
1
2
暴力枚举
//
// main.cpp
// A
//
// Created by zc on 2017/9/6.
// Copyright © 2017年 zc. All rights reserved.
//
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
ll n;
int main(int argc, const char * argv[]) {
while(~scanf("%lld",&n))
{
int ans=0;
for(int i=1;i<=15;i++)
{
ll sum=1;
for(int j=1;j<=i;j++)
{
sum*=(ll)i;
}
if(sum<=n) ans++;
else break;
}
printf("%d\n",ans);
}
}
You are given a positive integer n, please count how many positive integers k satisfy kk≤n.
Input
There are no more than 50 test cases.
Each case only contains a positivse integer n in a line.
1≤n≤1018
Output
For each test case, output an integer indicates the number of positive integers k satisfy kk≤n in
a line.
Sample Input
1
4
Sample Output
1
2
暴力枚举
//
// main.cpp
// A
//
// Created by zc on 2017/9/6.
// Copyright © 2017年 zc. All rights reserved.
//
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
ll n;
int main(int argc, const char * argv[]) {
while(~scanf("%lld",&n))
{
int ans=0;
for(int i=1;i<=15;i++)
{
ll sum=1;
for(int j=1;j<=i;j++)
{
sum*=(ll)i;
}
if(sum<=n) ans++;
else break;
}
printf("%d\n",ans);
}
}
相关文章推荐
- 2017ACM/ICPC广西邀请赛-A Math Problem
- HDU 6182 && 2017广西邀请赛:A Math Problem
- 2017ACM/ICPC广西邀请赛 A Math Problem
- HDU 6183 && 2017广西邀请赛:Color it(线段树)
- A Math Problem HDU - 6182 (快速幂)
- HDU 6185 Covering (2017 广西邀请赛重现赛)(矩阵快速幂)
- 【2017广西邀请赛】hdu 6186 CS Course
- 2017 广西邀请赛&& hdu 6191 Query on A Tree(字典树启发式合并)
- 【2017广西邀请赛】hdu 6184 Counting Stars 三元环+set
- HDU 6182 A Math Problem(水~)
- HDU 6185 && 2017广西邀请赛:Covering(矩阵快速幂)
- HDU 6191 2017广西邀请赛Query on A Tree:可持久化01字典树(区间抑或最大值查询)
- 【2017广西邀请赛】hdu 6188 Duizi and Shunzi 贪心
- A Math Problem (广西邀请赛-重现赛)
- HDU 6184&& 2017广西邀请赛 Counting Stars(三元环计数)
- HDU 6186 && 2017广西邀请赛:CS Course
- HDU 6191 && 2017广西邀请赛:Query on A Tree(字典树启发式合并)
- HDU-6186 CS Course (线段树)(2017ACM/ICPC广西邀请赛)
- HDU 6184 && 2017广西邀请赛:Counting Stars(三元环)
- 2017 ACM/ICPC 广西邀请赛||HDU 6185 Covering 【状压DP+矩阵快速幂】