Friday, March 25, 2016

Modulo of Big Number

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s=0, n, m, x, i;
    string a;
    cin>>a;
    cin>>m;
    n=a.size();
    for(i=0; i<n; i++){
        x=a[i]-48;
        s=(s*10+x)%m;
    }
    cout<<s<<endl;
    return 0;
}

No comments:

Post a Comment