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)