Description
Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing sequence of all prime numbers. We know that x > 1 can be represented in only one way in the form of product of powers of prime factors. This implies that there is an integer kx and uniquely determined integers ekx, ekx-1, ..., e1, e0, (ekx > 0), that The sequenceInput
The input consists of lines (at least one) each of which except the last contains prime base representation of just one positive integer greater than 2 and less or equal 32767. All numbers in the line are separated by one space. The last line contains number 0.Output
The output contains one line for each but the last line of the input. If x is a positive integer contained in a line of the input, the line in the output will contain x - 1 in prime base representation. All numbers in the line are separated by one space. There is no line in the output corresponding to the last ``null'' line of the input.Sample Input
17 1 5 1 2 1 509 1 59 1 0
Sample Output
2 4 3 2 13 1 11 1 7 1 5 1 3 1 2 1
Source
題目大意,輸入一行數,例如 a,b,c,d,e,f...... 然後問 a^b*c^d*e^f*.... 的結果減去1後由哪些素數可以乘得,輸出素數(由大到小)和個數,
對於此題我只想說 cmath 的pow(快速冪)函數對整型有誤差,且用且珍惜,最好手寫,(⊙o⊙)…
還有一點,題目說不會超 int 所以不用擔心什麼了
上代碼了,解釋在代碼中
#include#include #include #include using namespace std; #define N 100005 int a[N],b[N]; struct stud{ int a,len; }f[1000]; int k=0; void inset() //素數表 { int i,j; for(i=2;i =0;i--) if(i==0) printf("%d %d\n",f[i].a,f[i].len); else printf("%d %d ",f[i].a,f[i].len); } return 0; }