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 首先 ...
随机推荐
- httpd 隐藏文件
问题情况, 因磁盘空间问题,使用rsync将 php工作目录下文件copy到新盘中后,出现 php服务很多目录访问返回 404,路径找不到,其实文件都存在,而且路径都是对的 解决思路. 根目录下 有个 ...
- html5--3.18 新增的output元素
html5--3.18 新增的output元素 学习要点 了解output元素的用法 output元素:数据的输出 output元素是HTML5新增的元素,用来设置不同数据的输出 output元素的输 ...
- Thrift之代码生成器Compiler原理及源码详细解析1
我的新浪微博:http://weibo.com/freshairbrucewoo. 欢迎大家相互交流,共同提高技术. 又很久没有写博客了,最近忙着研究GlusterFS,本来周末打算写几篇博客的,但是 ...
- bzoj 4589 Hard Nim —— FWT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4589 先手必败,是一开始所有石子的异或和为0: 生成函数 (xpri[1] + xpri[2 ...
- Python批量操作Linux服务器执行命令
#-*- coding: utf-8 -*- #!/usr/bin/python import paramiko import threading def ssh2(ip,username,passw ...
- Rusty String
题意: 给定一个含有两种字符'V','K'以及?的字符串,问该串可能的循环节. 解法: 首先如果对于$d$,我们有不存在 $(j-i) | d$ 且 $S_i = 'V', S_j = 'K'$ 的 ...
- int和Integer及拆箱与装箱
int和Integer 如果面试官问Integer与int的区别:估计大多数人只会说道两点,Ingeter是int的包装类,int的初值为0,Ingeter的初值为null.但是如果面试官再问一下In ...
- Asset Catalog Help (十)---Specifying a Resizable Area of an Image
Specifying a Resizable Area of an Image Use the Xcode Slicing feature to specify the dimensions of a ...
- Asset Catalog Help (三)---Adding Image Sets
Adding Image Sets Organize versions of your images in image sets, which you can add to an asset cata ...
- 1.6-1.8 HBase表的物理模型
一.HBase 物理模型 1. 1.Table中的所有行都按照row key的字典序排列: 2.Table在行的方向上分割为多个Region: 3.Region按天小分割的,每个表开始只有一个regi ...