AlbertMourato

Untitled

Feb 22nd, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <bits/stdc++.h>
  3. //%lld
  4. typedef long long ll;
  5. using namespace std;
  6. int teto(int a, int b){
  7.     if(a%b!=0)return (a/b)+1;
  8.     return a/b;
  9. }
  10. int main(){
  11.     //freopen("in.txt", "r", stdin);
  12.     //freopen("out.txt", "w", stdout);
  13.     int a, b, q, r;
  14.     cin>>a>>b;
  15.     if(a<0&&b>0){
  16.         if(a!=(b*-1)){
  17.             q = a/b;
  18.             q--;
  19.             r = a-(q*b);
  20.             cout<<q<<" "<<r<<"\n";
  21.         }else{
  22.             cout<<"-1 0\n";
  23.         }
  24.     }else if(a<0&&b<0){
  25.         if(a<b){
  26.             q = a/b;
  27.             q++;
  28.             r = a-(q*b);
  29.         }else{
  30.             q = teto(a,b);
  31.             r = a-(q*b);
  32.         }
  33.         cout<<q<<" "<<r<<"\n";
  34.     }else{
  35.         q = a/b;
  36.         r = a-(q*b);
  37.         cout<<q<<" "<<r<<"\n";
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment