大数取余
(a? string? d=0; ? 描述 As we know,Big Number is always troublesome. But it's really important in our ACM. And today,your task is to write a program to calculate A mod B. 输入 The input contains several test cases. Each test case consists of two positive integers A and B. The length of A will not exceed 1000,and B will be smaller than 100000. Process to the end of file. 输出 For each test case,you have to ouput the result of A mod B. 样例输入 样例输出 ?
#include <iostream> using namespace std; int main() { string m; long n,d; int i; while (cin >> m >> n) { d = 0; for (i = 0; i < m.size(); i++) { d = ((d * 10) % n + m[i] - '0') % n; } cout << d << endl; } return 0; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |