HDU2441ACM(Array Complicated Manipulation)题解数论
来源:互联网 发布:淘宝我打软件 编辑:程序博客网 时间:2024/05/22 08:27
ACM(Array Complicated Manipulation)
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 204 Accepted Submission(s): 48
Problem Description
Given an infinite array of integers 2,3,.... Now do some operations on it.
The operation is to choose a minimum number from the array which is never been chosen, then change the status of its multiples excluding itself, i.e remove the multiples of the chosen number if they are in the array , otherwise add it to the array.keep the order after change.
For instance, the first step, choose number 2, change the status of 4, 6, 8, 10... They are all removed from the array. The second step, choose 3, change the status of 6, 9, 12, 15...
Pay attention: 9 and 15 are removed from the array while 6 and 12 are added to the array.
The operation is to choose a minimum number from the array which is never been chosen, then change the status of its multiples excluding itself, i.e remove the multiples of the chosen number if they are in the array , otherwise add it to the array.keep the order after change.
For instance, the first step, choose number 2, change the status of 4, 6, 8, 10... They are all removed from the array. The second step, choose 3, change the status of 6, 9, 12, 15...
Pay attention: 9 and 15 are removed from the array while 6 and 12 are added to the array.
Input
Every line contains an integer n. The zero value for n indicates the end of input.
Output
Print "yes" or "no" according whether n is in the array.
Sample Input
230900
Sample Output
yesyesnoHintThe number n never has a prime factor greater than 13000000, but n may be extremely large.
Source
2008 Asia Harbin Regional Contest Online
Recommend
gaojie
我先打表看小数据找规律
判断是否有重复的素因子
当m的素因子没有重复的时候,
当m的素因子没有重复的时候,
能改变m状态的数的个数有c(n,1)+c(n,2)+...+c(n,n-1)=2^n-c(n,0)-c(n,n)=2^n-2是一个偶数,改变偶数次回到原状态。
c(n,n)表示从m的n种素因子中选n种,当m的素因子没有重复的时候,选n个乘积就等于m了,所以不能选n个;
当m有重复素因子时,可以选n个不同的素因子,此时他们的乘积小于m,所以能选n个。
当m有重复素因子时,能改变n状态的数的个数加上c(n,n)=1变成了奇数,
当m有重复素因子时,能改变n状态的数的个数加上c(n,n)=1变成了奇数,
所以状态改变了,数m不存在了。
比如30=2*3*5 能改变它状态的数有(2,3,5),(6,10,15)偶数个,所以30存在
60=2*2*3*5 能改变它状态的数有(2,3,5),(6,10,15),(30)奇数个,所以60不存在
n表示m的素因子种类数。
注意1和高精度
注意1和高精度
- HDU2441ACM(Array Complicated Manipulation)题解数论
- hdu 2441-ACM(Array Complicated Manipulation)(数学)
- Subsets(Array/ Bit Manipulation )
- 数论 练习题【题解】
- (题解)数论的目录
- 【BZOJ】【P2818】【Gcd】【数论】【题解】
- 【POJ】【P2154】【Color】【题解】【数论】
- 【数论 Day2】基础归纳法 题解
- 【数论】17.6.3 计数 题解
- BZOJ3505 数三角形 题解 【数论】
- 【BZOJ3505】【数论】数三角形 题解
- 【BZOJ1008】【数论】[HNOI2008]越狱 题解
- codeforces A. Array题解
- LeetCode题解:Rotate Array
- 525. Contiguous Array 题解
- Complicated Declarations
- Complicated 歌词
- Complicated disputes
- C#源程序 打包成安装文件 的步骤
- JS判断浏览器是否是关闭
- 字节?
- Oracle大对象处理
- CSS Bug Table
- HDU2441ACM(Array Complicated Manipulation)题解数论
- ORACLE中LOB字段的使用和维护
- 常用 seo
- new
- Linux中.a,.la,.o,.so文件的意义和编程实现
- Oracle中的包――DBMS_LOB(一)
- 关于0racle中pl/sql调用java的实际应用(附代码)
- Javascript关键字(Reserved Words) 保留字
- 三个精灵说真话假话的判断难题