easy n%m

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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值