17115 Ooxx Numbers
Time limit: 1000MS memory limit: 65535K
Number of submissions: 0 Number of Passes: 0
Question types: programming language: 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, a) is a pair of ooxx numbers if a Is the OO number of B and B are the OO number of A.now I want to find how many pairs of Ooxx numbers in [1,n]
Input format
There is many cases in the input.for each line there is a number n. (1 <= n <= 5000000)
Output format
Input sample
3001300
Output sample
12
Tips
Hits 220=1+2+4+71+142=284,284=1+2+4+5+10+11+20+22+44+55+110=220. 280 is a pair of ooxx numbers.
Author
Admin
Obviously you can use Nlogn to complete book[i] to denote all the factors of the number of I and then hit the table. But the problem is still stuck nlogn. So I pay the table.
Use pair x y to indicate that they are the same pair of generators, and then ensure that x is less than Y, (this can be ensured when playing the table, from small to large enumeration, if any, will first enter)
Y is then prefixed and, because Y is greater than x, so y is meaningful. is 220 and 280, ask 250 is not, ask 280.
Pre[i] Indicates how many answers are in numbers less than or equal to I.
#include <cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>#defineIOS Ios::sync_with_stdio (False)using namespacestd;#defineINF (0X3F3F3F3F)typedefLong Long intLL; #include<iostream>#include<sstream>#include<vector>#include<Set>#include<map>#include<queue>#include<string>Const intMAXN =5000000+ -; LL BOOK[MAXN];structNode {intx, y; BOOL operator< (Const structNode & RHS)Const { if(X! =rhs.x) {returnX <rhs.x; } Else returnY <Rhs.y; }}A[MAXN];intX[MAXN] = {0, -,1184,2620,5020,6232,10744,12285,17296,63020,66928,67095,69615,79750,100485,122265,122368,141664,142310,171856,176272,185368,196724,280540,308620,319550,356408,437456,469028,503056,522405,600392,609928,624184,635624,643336,667964,726104,802725,879712,898216,947835,998104,1077890,1154450,1156870,1175265,1185376,1280565,1328470,1358595,1392368,1466150,1468324,1511930,1669910,1798875,2082464,2236570,2652728,2723792,2728726,2739704,2802416,2803580,3276856,3606850,3786904,3805264,4238984,4246130,4259750};intY[MAXN] = {0,284,1210,2924,5564,6368,10856,14595,18416,76084,66992,71145,87633,88730,124155,139815,123152,153176,168730,176336,180848,203432,202444,365084,389924,430402,399592,455344,486178,514736,525915,669688,686072,691256,712216,652664,783556,796696,863835,901424,980984,1125765,1043096,1099390, 1189150,1292570,1438983,1286744,1340235,1483850,1486845,1464592,1747930,1749212,1598470,2062570,1870245,2090656,2429030,2941672,2874064,3077354,2928136,2947216,3716164,3721544,3892670,4300136,4006736,4314616,4488910,4445050};intLena = in;//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 <=; ++i) {//cout << a[i].x << "<< a[i].y << Endl;// }//}intN;intPRE[MAXN];voidinit () { for(inti =1; I <= Lena; ++i) {Pre[y[i]]=1; } for(inti =1; I <= MAXN- -; ++i) {Pre[i]+ = Pre[i-1]; }}voidWork () {printf ("%d\n", Pre[n]);}intMain () {#ifdef local freopen ("Data.txt","R", stdin);#endifinit (); while(SCANF ("%d", &n)! =EOF) work (); return 0;}
View Code
17115 Ooxx Numbers table