题解 | #大整数的因子#

大整数的因子

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#
全部评论

相关推荐

06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务