最近看到一个网站, 欧拉计划.挺好玩,都是一些算法题.这是本站:http://projecteuler.net/problems 这个是中文站:http://pe.spiritzhang.com/ 下面贴两个小脚本,低端玩具 1.找出一个数的所有因子: #encoding:utf-8 import math def yinzi(n): list_yinzi = [] if n <= 2: return list_yinzi for i in range(2, int(math.sqrt(n))
Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8976 Accepted Submission(s): 3191 Problem Description Everybody knows any number can be combined by the prime number. Now
Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation. (Recall that the number of set bits an integer has is the number of 1s present when written in bin
题目: Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *...*pm^km. 输入描述: Each input file contains one test case which gives a positive integer N in the range of long int. 输出
7.7 Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7. 这道题跟之前LeetCode的那道Ugly Number II 丑陋数之二基本没有啥区别,具体讲解可参见那篇,代码如下: class Solution { public: int getKthMagicNumber(int k) { vector<, ); , i5 = , i7 = ; while (re
Easy Number Challenge Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 236B Appoint description: System Crawler (2016-04-26) Description Let's denote d(n) as the number of divisors of a