Description
Look at the following equation:
C =
AB -+ 1
Now given the valueC, How many possible values of andAAndBAre there (AAndBMust be positive integers )? That is you will have to find the number of Pairs(A,B)Which satisfies the above equation.
Input
The input file contains around 3000 line of input. Each line contains an IntegersN(0 <N1014). ThisNActually denotes the valueC. A line containing a single zero terminates the input. This line shoshould not be processed.
Output
For each line of input produce one line of output. This line contains two integers. First integer denotes the valueCAnd the second integer denotes the number of pair of valuesAAndBThat satisfies the above equation, given the valueC.
Sample Input
10204000
Sample output
1020 8400 2 Question: Finding equations is all the possibilities of CTrain of Thought: C = A ? B ? A + B 2 + 1 After factorization 4 ? C ? 3 = ( 2 ? A ? 1 ) ? ( 2 ? B ? 1 )
Therefore, this question can be converted to the composition of the factor of 4 * C-3, after finding the prime number of all the factors, is to use the partition method to split f [I] into two, is multiplied by F [I] + 1.
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> typedef long ll; using namespace STD; const int maxn = 22000000; int f [maxn], B [maxn]; int LP, P [maxn> 3], PRI [maxn]; void Init () {// pri [] minimum factor Lp = 0; For (INT I = 2; I <maxn; I ++) {If (! PRI [I]) P [LP ++] = pri [I] = I; for (Int J = 0; j <LP & I * P [J] <maxn; j ++) {pri [I * P [J] = P [J]; if (I % P [J] = 0) Break ;}}} void CAL (ll n, ll & L, int B [], int f []) {ll TMP, I = 0; L = 0; while (n> 1) {If (n <maxn) TMP = pri [N]; else {TMP = N; (; I <LP & N/P [I]> = P [I]; I ++) if (N % P [I] = 0) {TMP = P [I]; break;} f [l] = 0; while (N % TMP = 0) {n/= TMP; f [l] ++;} B [L ++] = TMP ;}} int main () {ll n, l; I Nit (); While (scanf ("% LLD", & N )! = EOF & N) {CAL (4 * N-3, L, B, F); LL sum = 1; for (INT I = 0; I <L; I ++) sum * = f [I] + 1; printf ("% LLD \ n", N, sum);} return 0 ;}