Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <bits/stdc++.h>
- //%lld
- typedef long long ll;
- using namespace std;
- int teto(int a, int b){
- if(a%b!=0)return (a/b)+1;
- return a/b;
- }
- int main(){
- //freopen("in.txt", "r", stdin);
- //freopen("out.txt", "w", stdout);
- int a, b, q, r;
- cin>>a>>b;
- if(a<0&&b>0){
- q = a/b;
- q--;
- r = a-(q*b);
- }else if(a<0&&b<0){
- if(a<b){
- q = a/b;
- q++;
- r = a-(q*b);
- }else{
- q = teto(a,b);
- r = a-(q*b);
- }
- }else{
- q = a/b;
- r = a-(q*b);
- }
- cout<<q<<" "<<r<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment