hdu 1212(大数取余)

来源:互联网 发布:营销软件honghailongt 编辑:程序博客网 时间:2024/06/04 19:03

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


题目大意:输入两个数a, b, 要求输出a mod b(a的长度小于1000, b <= 100000)(a 是长度, b是大小)


分析:直接代码,模板!模板!


ac代码

#include<cstdio>#include<string.h>#include<iostream>using namespace std;const int M = 100000;char a[M];int main(){int b, rem;while(scanf("%s %d", a, &b) != EOF){rem = 0;int len = strlen(a);for(int i = 0; i < len; i++){rem = rem * 10;rem = rem + (a[i] - '0');rem = rem % b;}printf("%d\n", rem);}return 0;}

0 0