13: Big integer factor, 13: integer factor

Source: Internet
Author: User

13: Big integer factor, 13: integer factor
13: the factor of the big integer

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
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 number of digits of a non-negative integer c and c <= 30.
Output
If there is a k that satisfies c % k = 0, all such k is output from small to large, and the adjacent two numbers are separated by a single space. If there is no such k, the output is "none ".
Sample Input
30
Sample output
2 3 5 6 

1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 using namespace std; 5 char a1 [10001]; 6 int a [10001]; 7 int c [10001]; 8 int tot; 9 int main () 10 {11 gets (a1); 12 int la = strlen (a1 ); 13 for (int I = 0; I <la; I ++) 14 {15 a [I + 1] = a1 [I]-48; 16} 17 int x = 0; // quotient 18 for (int j = 2; j <= 9; j ++) 19 {20 memset (c, 0, sizeof (c); 21 x = 0; 22 for (int I = 1; I <= la; I ++) 23 {24 c [I] = (x * 10 + a [I])/j; 25 x = (x * 10 + a [I]) % j; 26} 27 if (x = 0) 28 {29 tot ++; 30 cout <j <"; 31} 32} 33 if (tot = 0) 34 {35 cout <"none"; 36} 37/* int lc = 1; 38 for (int I = 1; I <= la; I ++) 39 {40 if (c [I] = 0 & lc <la) 41 lc ++; 42 else break; 43} 44 for (int I = lc; I <= la; I ++) 45 cout <c [I]; 46 cout <endl; 47 cout <x; */48 return 0; 49}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.