easy n%m
题目描述
I have a very simple problem for you. Given two integers n and m, your job is to calculate the n % m.
输入
The input will consist of a series of pairs of integers n and m, separated by a space, one pair of integers per line. n<=10100,1<=m<=109
输出
For each pair of input integers a and b you should output the n % m in one line, and with one line of output for each line in input.
样例输入
98757550230217155706156731058600777176 867
837742186949589961446822476827333 15260
751432949647353304314590769697032412519700 16334
样例输出
366
10753
7150
#include<iostream>
#include<string>
const int maxn=10000;
using namespace std;
int main()
{
ios::sync_with_stdio(false);//小妹的习惯不用管
cin.tie(0);cout.tie(0);
string a;//用字符串来存储大数
int mod;//这是你要取余的数
while(cin>>a>>mod)
{
int l=a.size();
int s[maxn];
int ans=0;
for(int i=0;i<l;i++)//这个就是把字符型数字变成整型数字
{
s[i]=a[i]-'0';
}
for(int i=0;i<l;i++)//每步一取模
{
ans=(ans*10+s[i])%mod;
}
cout<<ans<<endl;
}
return 0;
}