Large integer factor (high-precision MoD)

Source: Internet
Author: User

Factors of large integers
Total time limit:
1000ms
Memory Limit:
65536kB
Describe

Known positive integer k satisfies 2<=k<=9, now gives the maximum length of 30 bits of the decimal non-negative integer c, for all can be divisible C K.

Input
A non-negative integer c,c the number of digits <=30.
Output

If there are c%k = = 0 K, from small to large output all such k, adjacent two numbers separated by a single space; if there is no such k, output "none".

Sample input

30

Sample output

2 3 5 6

Code

Gao operations

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>using namespacestd;intx[ -],y[ -],k[ -],j=0, M,n;Chara[ -],b[ -];intMain () {scanf ("%s", a); M=strlen (a);  for(intI=0; i<=m; i++) X[i+1]=a[i]-'0';  for(intp=2; p<=9; p++) {memcpy (k,x,sizeof(x));  for(intI=1; i<=m+1; i++) {K[i+1]+= (k[i]%p) *Ten; Y[i]=k[i]%p; K[i]=k[i]/p; }        if(y[m]==0) {cout<<p<<" "; J++; }     }    if(j==0) cout<<"None"; return 0;}

Zlycerqan

#include <iostream>using namespacestd;inta[Ten],f=0;stringT;intMain () {CIN>>T;  for(inti =0; T[i]; i++)         for(intj =2; J <=9; J + +) A[j]= (A[j] *Ten+ T[i]-'0') %J;  for(inti =2; I <=9; i++)    if(!A[i]) {cout<< I <<' '; F=1; }    if(!f) cout<<"None"; return 0;}

Large integer factor (high-precision MoD)

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.