17115 ooxx numbers 交表
17115 ooxx numbers
时间限制:1000MS 内存限制:65535K
提交次数:0 通过次数:0
题型: 编程题 语言: G++;GCC
Description
a number A called oo number of a number B if the sum of all As factor is the number B.
(A,B) is a pair of ooxx numbers if A is the oo number of B and B is the oo number of A.
Now i want to find how many pairs of ooxx numbers in [1,n]
输入格式
there are many cases in the input.
for each line there is a number n. ( 1 <= n <= 5000000 )
输出格式
for each n, output the numbers of pairs of ooxx numbers in [1,n]
输入样例
300
1300
输出样例
1
2
提示
hits
220=1+2+4+71+142=284,
284=1+2+4+5+10+11+20+22+44+55+110=220。
220 and 280 is a pair of ooxx numbers.
作者
admin
明显可以用nlogn完成book[i]表示i这个数的所有因子和,然后打表。但是题目还是卡了nlogn。所以就交表。
用pair x y表示他们是同一对生成元,然后保证x是小于y的,(这个在打表的时候可以确保,从小到大枚举,如果有的话,就会先进入了)
然后对y进行前缀和,因为y是大于x的,所以y才是有意义的。就是220和280,问250是没有的,问280才行。
pre[i]表示小于等于i的数字中有多少个答案。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = + ;
LL book[maxn];
struct node {
int x, y;
bool operator < (const struct node & rhs) const {
if (x != rhs.x) {
return x < rhs.x;
} else return y < rhs.y;
}
}a[maxn];
int x[maxn] = {, , , , , , , , , , , , , , , , ,, , , , , , , , , , , , , , , ,
, , , , , , , , , , ,
, , , , , , , , , , , , , , , , , , , , , , , , , , , }; int y[maxn] = {, , , , , , , , , , , , , , , , ,, , , , , , , , , , , , , , , , , , , , , , , , , , ,
, , , , , , , , , , , ,, , , , , , , , , , , , , , , };
int lena = ;
//bool vis[maxn];
//void init() {
// for (int i = 1; i <= maxn - 20; ++i) {
// for (int j = 2 * i; j <= maxn - 20; j += i) {
// book[j] += i;
// }
// }
// lena = 0;
// for (int i = 1; i <= maxn - 20; ++i) {
// if (book[i] <= maxn - 20) {
// if (!vis[i] && book[book[i]] == i && book[i] != i) {
// ++lena;
// a[lena].x = i;
// a[lena].y = book[i];
// vis[i] = true;
// vis[book[i]] = true;
// }
// }
// }
// sort(a + 1, a + 1 + lena);
// for (int i = 1; i <= maxn - 20; ++i) {
// x[i] = a[i].x;
// y[i] = a[i].y;
// }
// for (int i = 1; i <= 10; ++i) {
// cout << a[i].x << " " << a[i].y << endl;
// }
//}
int n;
int pre[maxn];
void init() {
for (int i = ; i <= lena; ++i) {
pre[y[i]] = ;
}
for (int i = ; i <= maxn - ; ++i) {
pre[i] += pre[i - ];
}
}
void work() {
printf("%d\n", pre[n]);
}
int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
init();
while (scanf("%d", &n) != EOF) work();
return ;
}
17115 ooxx numbers 交表的更多相关文章
- SCAU 13校赛 17115 ooxx numbers
17115 ooxx numbers 时间限制:1000MS 内存限制:65535K 题型: 编程题 语言: 无限制 Description a number A called oo numbe ...
- Uva 10820 交表
题目链接:https://uva.onlinejudge.org/external/108/10820.pdf 题意: 对于两个整数 x,y,输出一个函数f(x,y),有个选手想交表,但是,表太大,需 ...
- HDOJ 1058 Humble Numbers(打表过)
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- hdu 5676 ztr loves lucky numbers 打表+二分
ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/ ...
- SQL Server ->> 生成Numbers辅助表
if object_id('MyDB.dbo.Numbers') is not null drop table MyDB.dbo.Numbers go use [MyDB] go create tab ...
- jsp-提交表单时,select的值无法传递
属性为"disabled",提交表单时,select的值无法传递,移除disabled属性,<input name="id" type="tex ...
- jsp--提交表单→插入数据库→成功后返回提示信息
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="u ...
- poj1338 Ugly Numbers 打表, 递推
题意:一个数的质因子能是2, 3, 5, 那么这个数是丑数. 思路: 打表或者递推. 打表: 若该数为丑数,那么一定能被2 或者3, 或者5 整除, 除完之后则为1. #include <ios ...
- 51nod 1010 只包含因子2 3 5的数 && poj - 1338 Ugly Numbers(打表)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 http://poj.org/problem?id=1338 首先 ...
随机推荐
- ansible操作模块相关
1. 查看模块可用参数命令 ansible-doc -s module_name
- BZOJ 1628 [Usaco2007 Demo]City skyline:单调栈
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1628 题意: 题解: 单调栈. 单调性: 栈内元素高度递增. 一旦出现比栈顶小的元素,则表 ...
- eclipse 卡死设置
都说eclipse比myeclipse小巧,但是 殊不知 用起来这么这么的卡,最后查资料,才知道是 配置给他的内存太 太小了,怪不得 他一直想着罢工呢. 在eclipse.ini文件中原来的配置如下: ...
- 机器学习(十六)— LDA和PCA降维
一.LDA算法 基本思想:LDA是一种监督学习的降维技术,也就是说它的数据集的每个样本是有类别输出的.这点和PCA不同.PCA是不考虑样本类别输出的无监督降维技术. 我们要将数据在低维度上进行投影,投 ...
- 看 迪杰斯特拉(Dijsktra)算法体会
迪杰斯特拉 看啊哈算法中迪杰斯特拉算法体会: 算法思路 : 1.先找到源头到其他点的最短路: 2.以最短路作为中转点进行比较,用一个dis数组保存源头到他的最优距离 3.用循环进行最优筛选: #inc ...
- 001-将Python源码转换为不需要环境的可执行文件
1 安装pyinstaller pip install pyinstaller #或者 pip3 install pyinstaller 2 生成打包文件 在命令行中输入 pyinstaller -F ...
- SPOJcot2 Count on a tree II (树上莫队)
You are given a tree with N nodes. The tree nodes are numbered from 1 to N. Each node has an integer ...
- 基于aspect实现AOP——xml配置的其他操作
将上方配置中的前置通知,可换成环绕通知
- Lsyncd搭建同步镜像-用Lsyncd实现本地和远程服务器之间实时同步
Lysncd即Live Syncing Daemon,它是开源的数据实时同步工具(后台进程),基于inotify和rsync. lsyncd会密切监测本地服务器上的参照目录,当发现目录下有文件或目录变 ...
- ubuntu16.04 NVIDIA 驱动安装
查看驱动版本号 查看驱动适用版本:NVIDIA驱动版本查询 查看显卡对应的驱动版本: 举例如下: 禁止集成的nouveau驱动 Ubuntu系统集成的显卡驱动程序是nouveau,它是第三方为NVID ...