题目大意:

给定一个long long 型的数 n,找到一共有多少对a,b,使比n小的某一个数的是a*b的倍数

这样我们可以理解为

存在a*b*c <= n,令 a <= b <= c ,当a=b=c时,存在一组 , a=b时,存在3组,均不相同,那么存在6组

且a <= pow(n , 1.0/3)   b <= pow(n/a , 1.0/2)

那么复杂度就缩小为 a*b了

注意过程中均为long long 型的数返回,否则数据大了会出现误差

#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL; LL getPowThird(LL x)
{
LL a = pow(x , 1.0 / );
while(a*a*a <= x) a++;
while(a*a*a > x) a--;
return a;
} LL getPowBinary(LL x)
{
LL a = pow(x , 1.0 / );
while(a*a <= x) a++;
while(a*a > x) a--;
return a;
}
int main()
{
// freopen("test.in","rb",stdin); LL n ;
int cas = ;
while(scanf("%I64d",&n)!=EOF){
LL ans = ; LL a = getPowThird(n);
LL np;
for(int i = ; i <= a ;i++){
np = n / i;
LL b = getPowBinary(np);
for(int j = i ; j <= b ;j++){
LL t = np/j;
if(i == j){
ans += (LL) * (t-j) + ;
}
else ans += (LL)* (t-j) + ;
}
} printf("Case %d: %I64d\n", ++cas , ans);
}
return ;
}

HDU 4473的更多相关文章

  1. HDU 4473 Exam 枚举

    原题转化为求a*b*c <=n中选出两个数组成有序对<a,b>的选法数. 令a<=b<=c.... 分情况讨论: (1)全部相等,即a = b = c. 选法有n^(1/ ...

  2. hdu 4473 Exam 数学

    思路: 将条件转化为满足abc<=n的abc的数目. 1.3个数相等时,为 A; 2.有2个数相等时,为 B; 3.都不相等时,为 C. 则结果为A+3*B+6*C. 代码如下: #includ ...

  3. HUD 4473 Exam

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4473 题目意思 定义f(x) = 满足(a * b)|x的有序对(a,b)的个数. 然后输入一个n, ...

  4. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  5. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  7. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  8. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  9. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. 对dynamic和lambda的学习

    var, object, dynamic的区别以及使用 dynamic(2) – ExpandoObject的使用 .NET中的Lambda表达式与匿名方法

  2. 转-NSUserDefaults 简介,使用 NSUserDefaults 存储自定义对象

    转自:http://my.oschina.net/u/1245365/blog/294449 摘要 NSUserDefaults适合存储轻量级的本地数据,一些简单的数据(NSString类型的)例如密 ...

  3. chart.js图表 传值问题

    php:         $json['status'] = ture;                $json['list']=implode(',',$data);                ...

  4. Farseer.net轻量级ORM开源框架 V1.0 开发目标

    本篇主要给大家说明下在V1.0中,计划开发的任务的状态.按照国际惯例.上大表格 开发计划状态 编号 模块 状态 说明 1  分离Utils.Extend.UI  √  在V0.2版本中,是集成在一个项 ...

  5. leetcode_1011. Capacity To Ship Packages Within D Days_binary search二分

    https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/ 传送带每天有最大传送量V,对于n个货物[w1,w2,w3. ...

  6. scrapy 的分页爬取 CrawlSpider

    1.创建scrapy工程:scrapy startproject projectName 2.创建爬虫文件:scrapy genspider -t crawl spiderName www.xxx.c ...

  7. sql中的日期时间处理

    每个数据库,不同的日期格式化: 1.mysql 2.sqlserver 使用Convert()函数: select convert(char(10),GetDate(),120) as Date 第3 ...

  8. python连接mysql的操作

    一,安装mysql 如果是windows 用户,mysql 的安装非常简单,直接下载安装文件,双击安装文件一步一步进行操作即可. Linux 下的安装可能会更加简单,除了下载安装包进行安装外,一般的l ...

  9. Oracle反向字符截取逗號分隔字符串

    DECLARE M ); BEGIN FOR I IN ( WITH T AS (SELECT REVERSE('i,am,a,test,hahahhah') AS STR FROM DUAL) SE ...

  10. April Fools Day Contest 2019: editorial回顾补题

    A. Thanos Sort time limit per test 1 second memory limit per test 256 megabytes input standard input ...