题解 | #大整数的因子#
大整数的因子
https://www.nowcoder.com/practice/3d6cee12fbf54ea99bb165cbaba5823d?tpId=40&tqId=21370&rp=1&ru=/ta/kaoyan&qru=/ta/kaoyan&difficulty=&judgeStatus=&tags=/question-ranking
#include <stdio.h> #include <string.h> //只需要考虑余数的大数除法 int main() { char arr[30]; while (scanf("%s", arr) != EOF) { char end[] = "-1"; if (strcmp(arr, end) == 0){ printf("none\n"); break; } int len = strlen(arr); int tag = 0; for (int i=2;i<10;i++){ int yushu=0; for (int j=0;j<len;j++){ int num = arr[j]-'0'+yushu*10; yushu = num%i; } if(yushu == 0){ if (tag){ printf(" %d",i); }else { printf("%d",i); tag = 1; } } } if (tag){ printf("\n"); }else { printf("none\n"); } } return 0; }#c#