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 交表的更多相关文章

  1. SCAU 13校赛 17115 ooxx numbers

    17115 ooxx numbers 时间限制:1000MS  内存限制:65535K 题型: 编程题   语言: 无限制 Description a number A called oo numbe ...

  2. Uva 10820 交表

    题目链接:https://uva.onlinejudge.org/external/108/10820.pdf 题意: 对于两个整数 x,y,输出一个函数f(x,y),有个选手想交表,但是,表太大,需 ...

  3. HDOJ 1058 Humble Numbers(打表过)

    Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...

  4. hdu 5676 ztr loves lucky numbers 打表+二分

    ztr loves lucky numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/ ...

  5. SQL Server ->> 生成Numbers辅助表

    if object_id('MyDB.dbo.Numbers') is not null drop table MyDB.dbo.Numbers go use [MyDB] go create tab ...

  6. jsp-提交表单时,select的值无法传递

    属性为"disabled",提交表单时,select的值无法传递,移除disabled属性,<input name="id" type="tex ...

  7. jsp--提交表单→插入数据库→成功后返回提示信息

    <%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="u ...

  8. poj1338 Ugly Numbers 打表, 递推

    题意:一个数的质因子能是2, 3, 5, 那么这个数是丑数. 思路: 打表或者递推. 打表: 若该数为丑数,那么一定能被2 或者3, 或者5 整除, 除完之后则为1. #include <ios ...

  9. 51nod 1010 只包含因子2 3 5的数 && poj - 1338 Ugly Numbers(打表)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1010 http://poj.org/problem?id=1338 首先 ...

随机推荐

  1. php排序方法之快速排序

    $arr = array(3,55,45,2,67,76,6.7,-65,85,4); function quickSort($arr){ if (count($arr) <= 1){ retu ...

  2. css父元素背景覆盖其子元素背景

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. Struts2 Action 匹配的几种方式

    下面针对我所遇见的Action的配置方法进行一下总结: 1.基本的匹配方法

  4. 疯狂LCM

    传送门 题目要求求: \[\sum_{i=1}^nlcm(i,n)\] 先转化成gcd处理: \[n\sum_{i=1}^n\frac{i}{gcd(i,j)}\] 之后老套路 枚举gcd,并且先把d ...

  5. hibernate学习三 精解Hibernate之核心文件

    一 hibernate.cfg.xml详解 1 JDBC连接: 2 配置C3P0连接池: 3 配置JNDI数据源: 4 可选的配置属性: 5 hibernate二级缓存属性 6 hibernate事务 ...

  6. GetModuleFileNameW

    GetModuleFileNameW( HMODULE hModule, //模块句柄 或应用程序的实例句柄 若参数为NULL,则返回该应用程序全路径 __out_ecount(nSize) LPWS ...

  7. 抓屏工具 faststone capture

    百度百科 http://baike.baidu.com/link?url=te51CfOKYIEmqT1jsyRwcB8Pnals5xQ8nUXk6trvBPGSJRBO5G7BEZL7cYQxmx8 ...

  8. Sandy and Nuts

    题意: 现在有一个$n$个点的树形图被拆开,现在你知道其中$m$条边,已经$q$对点的$LCA$,试求原先的树有多少种可能. 解法: 考虑$dp$,$f(x,S)$表示$x$的子树内的点集为$S$(不 ...

  9. python GUI尝鲜(但当涉猎,见往事耳)

    第一步:简单的窗口和内容 import tkinter as tk window = tk.Tk() # 窗口obj对象 window.title('my TK') # 窗口名字 window.geo ...

  10. java集合框架之比较器Comparator、Comparable

    参考http://how2j.cn/k/collection/collection-comparator-comparable/693.html Comparator 假设Hero有三个属性 name ...