SCAU 13校赛 17115 ooxx numbers
17115 ooxx numbers
时间限制:1000MS 内存限制:65535K
题型: 编程题 语言: 无限制
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
解题思路
这题是华农13年校赛的其中一题,当初没有过,如果过了就有一等奖了,没想到这题是打表题,没有经验就想不到有这种处理方式,所以还是学到东西了,当时ZF牛打表出了点差错也没有过,回头很快的秒掉了,真的很快,这次重新写的时候还是Wa了,因为处理因子上出了点差错,将可开根的数的因子少算了一个,导致最后打出的表少了一个数据,跪了。还有一个比较傻逼的问题就是,打表就是打表,不用太在乎效率,没想到我连打表都尽量减少其运行的时间,好几个判断的条件,还是不小心折腾了一番,_(:з」∠)_
ZF大神求因子和的方法:筛素数的思维方式筛出因子和,每个i为因子,j为i的倍数,值得借鉴
相比之下自己求因子和的方法,太挫了 -_-||:
1 #include<iostream> 2 #include<cstdio> 3 #include<string> 4 #include<cstring> 5 #include<cmath> 6 #include<algorithm> 7 8 using namespace std; 9 10 int digit[74]; 11 12 int main() 13 { 14 digit[0] = 1; 15 digit[1] = 284; 16 digit[2] = 1210; 17 digit[3] = 2924; 18 digit[4] = 5564; 19 digit[5] = 6368; 20 digit[6] = 10856; 21 digit[7] = 14595; 22 digit[8] = 18416; 23 digit[9] = 66992; 24 digit[10] = 71145; 25 digit[11] = 76084; 26 digit[12] = 87633; 27 digit[13] = 88730; 28 digit[14] = 123152; 29 digit[15] = 124155; 30 digit[16] = 139815; 31 digit[17] = 153176; 32 digit[18] = 168730; 33 digit[19] = 176336; 34 digit[20] = 180848; 35 digit[21] = 202444; 36 digit[22] = 203432; 37 digit[23] = 365084; 38 digit[24] = 389924; 39 digit[25] = 399592; 40 digit[26] = 430402; 41 digit[27] = 455344; 42 digit[28] = 486178; 43 digit[29] = 514736; 44 digit[30] = 525915; 45 digit[31] = 652664; 46 digit[32] = 669688; 47 digit[33] = 686072; 48 digit[34] = 691256; 49 digit[35] = 712216; 50 digit[36] = 783556; 51 digit[37] = 796696; 52 digit[38] = 863835; 53 digit[39] = 901424; 54 digit[40] = 980984; 55 digit[41] = 1043096; 56 digit[42] = 1099390; 57 digit[43] = 1125765; 58 digit[44] = 1189150; 59 digit[45] = 1286744; 60 digit[46] = 1292570; 61 digit[47] = 1340235; 62 digit[48] = 1438983; 63 digit[49] = 1464592; 64 digit[50] = 1483850; 65 digit[51] = 1486845; 66 digit[52] = 1598470; 67 digit[53] = 1747930; 68 digit[54] = 1749212; 69 digit[55] = 1870245; 70 digit[56] = 2062570; 71 digit[57] = 2090656; 72 digit[58] = 2429030; 73 digit[59] = 2874064; 74 digit[60] = 2928136; 75 digit[61] = 2941672; 76 digit[62] = 2947216; 77 digit[63] = 3077354; 78 digit[64] = 3716164; 79 digit[65] = 3721544; 80 digit[66] = 3892670; 81 digit[67] = 4006736; 82 digit[68] = 4300136; 83 digit[69] = 4314616; 84 digit[70] = 4445050; 85 digit[71] = 4488910; 86 87 sort(digit, digit+72); 88 int n; 89 while(scanf("%d", &n) != EOF) 90 { 91 int i = 0; 92 for(; i<=71; ++i) 93 if(digit[i] > n) break; 94 printf("%d\n", i-1); 95 } 96 return 0; 97 }
![物役记](https://s2.ax1x.com/2019/05/26/VE5YD0.jpg)
更多内容请关注个人微信公众号 物役记 (微信号:materialchains)
作者:雪影蓝枫
本文版权归作者和博客园共有,欢迎转载,未经作者同意须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。