Description
The positive integer k is known to satisfy 2 <= k <= 9. Now, a decimal non-negative integer c with a maximum length of 30 digits is given, and all K that can divide C is obtained.
-
Input
-
The input is read from the bignum. In file.The number of digits of several non-negative integers C and C <= 30. Each row has one C and is aborted when C =-1 (do not calculate-1 !)
-
Output
-
Save the result to bignum. Out., Each result of C occupies a row.
1) if there is a K that satisfies C % K = 0, output all such K, separated by spaces in the middle, and followed by spaces in the last K.
2) if no such K is available, "NONE" is output ".
Simulation questions
# Include <stdio. h> # include <iostream> # include <fstream> # include <memory. h> using namespace STD; ifstream fin ("bignum. in "); ofstream fout (" bignum. out "); # define CIN fin # define cout foutchar list [100]; int num [100]; int total; int F () {int K = 0; int num2 [100]; memcpy (num2, num, total * sizeof (INT); For (INT I = 1; I <total-2; I ++) {k = 10 * num2 [I-1] + num2 [I]; num2 [I-1] = 0; If (K % 7) {num2 [I] = K % 7 ;} else {num2 [I] = 0 ;}} return (100 * num2 [Total-3] + 10 * num2 [Total-2] + num2 [Total-1]) % 7 = 0);} int test () {bool Jud = 0; If (Total = 1) {If (Num [0] % 7 = 0) Jud = 1;} If (Total = 2) {If (10 * num [Total-2] + num [Total-1]) % 7 = 0) Jud = 1;} If (Total = 3) {If (100 * num [Total-3] + 10 * num [Total-2] + num [Total-1]) % 7 = 0) Jud = 1 ;} if (total> 3) Jud = f (); If (Jud = 1) return 1; else return 0;} int main () {While (scanf ("% s", list )! = EOF) {If (list [0] = '-') break; bool Jud [10] = {}; bool cont = 0; Total = 0; memset (Num, 0, sizeof (Num); For (INT I = 0; I <100; I ++) {If (list [I] = '\ 0') break; num [I] = list [I]-'0'; Total = I + 1;} If (Num [Total-1] % 2 = 0) {printf ("2"); Jud [2] = 1; cont ++;} int sub = 0; For (INT I = 0; I <total; I ++) {sub + = num [I];} If (sub % 3 = 0) {printf ("3"); Jud [3] = 1; cont ++ ;} if (Total = 1) {If (Num [0] % 4 = 0) {printf ("4"); Jud [4] = 1 ;}} else if (10 * num [Total-2] + num [Total-1]) % 4 = 0) printf ("4 "); if (Num [Total-1] = 0 | num [Total-1] = 5) {printf ("5"); cont ++ ;} if (Jud [2] = 1 & Jud [3] = 1) printf ("6"); If (test () {printf ("7 "); cont ++;} If (total> 2) {If (100 * num [Total-3] + 10 * num [Total-2] + num [Total-1]) % 8 = 0) printf ("8");} else if (10 * num [Total-2] + num [Total-1]) % 8 = 0) printf ("8"); If (sub % 9 = 0) printf ("9"); If (cont = 0) printf ("NONE "); printf ("\ n ");}}