大数取模 HDU 5832

    xiaoxiao2026-02-28  6

    int mod(char str[],int num) { int remainder=0; int len = strlen(str); for(int i=0;i<len;i++) { remainder=(remainder*10+(str[i] - '0'))%num; } return remainder; }

    HDU 5832

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5832

    题意:能被73和137整除就输出YES。

    #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char str[10000100]; int mod(char str[],int num) { int remainder=0; int len = strlen(str); for(int i=0;i<len;i++) { remainder=(remainder*10+(str[i] - '0'))%num; } return remainder; } int main() { int kase = 1; while(~scanf("%s", str)) { printf("Case #%d: ", kase++); if(mod(str, 73) == 0 && mod(str, 137) == 0) puts("YES"); else puts("NO"); } return 0; }

    转载请注明原文地址: https://ju.6miu.com/read-1307479.html
    最新回复(0)