TOJ 1203.Factoring Large Numbers
One of the central idea behind much cryptography is that factoring large numbers is computationally intensive. In this context one might use a 100 digit number that was a product of two 50 digit prime numbers. Even with the fastest projected computers this factorization will take hundreds of years.
You don’t have those computers available, but if you are clever you can still factor fairly large numbers.Input
The input will be a sequence of integer values, one per line, terminated by a negative number. The numbers will fit in gcc’s long long int datatype.
Output
Each positive number from the input must be factored and all factors (other than 1) printed out. The factors must be printed in ascending order with 4 leading spaces preceding a left justified number, and followed by a single blank line.
······
大數求因子的題,本來以為會超時,結果也沒有,通過這道題堅信了自己平常使用的求因子、質數的方法還是蠻快的嘛。水題上程式碼不多說。
#include <stdio.h>
using namespace std;
int main(){
long long num;
while(~scanf("%lld",&num) && num!=-1){
for(long long i=2;i*i<=num;i++)
while(!(num%i)){
num/=i;
printf (" %lld\n",i);
}
if(num>1)
printf(" %lld\n",num);
printf("\n");
}
}
相關推薦
TOJ 1203.Factoring Large Numbers
One of the central idea behind much cryptography is that factoring large numbers is computationa
UVa 10392 Factoring Large Numbers (素因子分解)
10392 - Factoring Large Numbers Time limit: 3.000 seconds One of the central ideas behind much cryptography is that factoring large nu
TOJ 1203: Number Sequence
contains http tom log .html clu image ons medium 1203: Number Sequence Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KBy
中心極限定理 | central limit theorem | 大數定律 | law of large numbers
lar 導致 ber 品茶 question 出了 numbers .com 沒有 每個大學教材上都會提到這個定理,枯燥地給出了定義和公式,並沒有解釋來龍去脈,導致大多數人望而生畏,並沒有理解它的美。 《女士品茶》有感 待續~ 參考:怎樣理解和區分中
Codeforces 55D Beautiful numbers(數位dp)
pac urn etc number div clu 能夠 是我 tdi 題目大意:T(<=10)組數據,求[a,b]能夠被其每個數位的數都整除的數(a,b<=9*10^18) 這題差一點就想出來了,可是最後一步好難想也好妙啊 首先這個數能夠整除各個
poj 3252 Round Numbers 數位dp
變量 數量 div read sdn .net blog air ble 題目鏈接: http://poj.org/problem?id=3252 題意: 求一段區間中二進制中0的數量要不能少於1的數量的數的個數。 思路: 套路 都是套路 http://blog.csdn
Ng第十七課:大規模機器學習(Large Scale Machine Learning)
在線 src 化簡 ima 機器學習 learning 大型數據集 machine cnblogs 17.1 大型數據集的學習 17.2 隨機梯度下降法 17.3 微型批量梯度下降 17.4 隨機梯度下降收斂 17.5 在線學習 17.6 映射化簡和數據並行
LeetCode---------Add Two Numbers 解法
eve n-n pty lead http 順序 number sum represent You are given two non-empty linked lists representing two non-negative integers. The digits
[LeetCode] Add Two Numbers
std 轉化 代碼 single ria 多種解法 ret data -m You are given two linked lists representing two non-negative numbers. The digits are stored in
3N Numbers
line following sel constrain positive second turn log cte D - 3N Numbers Time limit : 2sec / Memory limit : 256MB Score : 500 point
[Intermediate Algorithm] - Sum All Odd Fibonacci Numbers
org nac mil 數列 個數字 code target reference ava 題目 給一個正整數num,返回小於或等於num的斐波納契奇數之和。 斐波納契數列中的前幾個數字是 1、1、2、3、5 和 8,隨後的每一個數字都是前兩個數字之和。 例如,sumFib
leetcode鏈表--14、add-two-numbers(兩鏈表相加 得到新鏈表)
logs 錯誤 align 描述 eight val str nodes sent 題目描述 You are given two linked lists representing two non-negative numbers. The digits are sto
UVA 10042 Smith Numbers(數論)
sizeof ret col 保存 進行 uva nal isp published Smith Numbers Background While skimming his phone directory in 1982, Albert Wilansky, a ma
TOJ4101.Guess Game(TOJ means Tianjin University Online Judge)(dp的思想,但這道題目是假dp)
line bre 個人 eof ret calculate code stdio.h turn 題意:你要從[1,n]這個n個數中猜出來規定的某個數,現在這個數未知,問你在最糟糕的情況下(但是你采用了最優的策略),你要猜多少次才能猜出這個數。現在有兩種條件: 第一種:當你猜
數據可視化入門之show me the numbers
推薦 有趣的 好的 style blank 分享 span 需要 width 數據的可視化一直是自己瞎玩著學,近來想系統的學數據可視化的東西,於是搜索資料時看到有人推薦《show me the numbers》作為入門。 由於搜不到具體的書籍內容,只能搜到一個
Leetcode Add two numbers
current linklist number list main popu val post tail #include <iostream> using namespace std; struct ListNode { int val;
Packet for query is too large (1166 > 1024). You can change this value
win you 修改配置 服務 grep can hang sql 目前 轉載: MySQL max_allowed_packet 設置過小導致記錄寫入失敗 mysql根據配置文件會限制server接受的數據包大小。 有時候大的插入和更新會受max_allowed_p
URAL 2031. Overturned Numbers (枚舉)
tin width mes bit imu ger digi all under 2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surf
Humble Numbers(醜數) 超詳解!
then 每一個 %d sample 如果 nbsp 輸出 define clu 給定一個素數集合 S = { p[1],p[2],...,p[k] },大於 1 且素因子都屬於 S 的數我們成為醜數(Humble Numbers or Ugly Numbers),記第 n
[LeetCode] 448.Find All Numbers Disappeared in an Array
return htm put lis inpu pear rand ati n) p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4e9072 } p.p2 { margin: 0.0