Advertisement
mehedi1

mod using string (handling all negetive).cpp

Nov 21st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n,cas=0,T;
  6.   string str;
  7.   cin>>T;
  8.   while(T--) {
  9.     cin>>str>>n;
  10.     long long r=0;
  11.     int i;
  12.     if(str[0]=='-') i=1;
  13.     else i=0;
  14.     for(;str[i];++i) {
  15.       r=r*10+(str[i]-'0');
  16.       r=r%n;
  17.     }
  18.     printf("Case %d: remainder=%lld\n",++cas,r);
  19.   }
  20.   return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement