CSES - Leirikisa 1 - Results
Submission details
Task:kusac
Sender:Kuha
Submission time:2016-07-27 14:26:17 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:29:37: error: invalid operands of types 'void' and '<unresolved overloaded function type>' to binary 'operator<<'
     if (!n) cout<<0<<endl, exit(0)<<endl;
                                     ^

Code

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define N (1<<17)
#define M 1000000007

using namespace std;

int gcd(int a, int b) {
 if (!b) return a;
return gcd(b, a % b); 
}

int main () {
  int n, m;
  cin>>n>>m;
  if (n == m) cout<<0<<endl;
  else if (n < m) {
    int ans = n * (m % n);
    m -= m % n;
    if (n == m) cout<<ans<<endl;
    else {
	m /= n;
	ans += n * m - n;
	cout<<ans<<endl;
    }
  } else {
    n = n % m;
    if (!n) cout<<0<<endl, exit(0)<<endl;
    int ans = n * (m % n);
    m -= m % n;
    if (n == m) cout<<ans<<endl;
    else {
	m /= n;
	ans += n * m - n;
	cout<<ans<<endl;
    }
  }
}