CSES - Leirikisa 1 - Results
Submission details
Task:kusac
Sender:Kuha
Submission time:2016-07-27 15:01:40 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.05 sdetails
#20.05 sdetails
#30.06 sdetails
#40.05 sdetails
#50.05 sdetails
#60.05 sdetails
#70.05 sdetails
#80.05 sdetails
#90.05 sdetails
#100.05 sdetails
#110.06 sdetails

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;
  n = n % m;
  int ans = 0;
  if (!n) cout<<0<<endl;
  else if (n == m) cout<<0<<endl;
  else if (n < m) {
    int l = m;
    ans += n * (l / n);
    l %= n;
    cout<<ans<<endl;
    if (!l) ans -= n;
    if (l) {
      if (n % l) {
	ans += l - 1;
      }
    }
  }
  cout<<ans<<endl;
}

Test details

Test 1

Verdict:

input
2 6

correct output
4

user output
6
4

Test 2

Verdict:

input
3 4

correct output
3

user output
3
3

Test 3

Verdict:

input
6 2

correct output
0

user output
0
0

Test 4

Verdict:

input
7 7

correct output
0

user output
0
0

Test 5

Verdict:

input
15 5

correct output
0

user output
0
0

Test 6

Verdict:

input
15 16

correct output
15

user output
15
15

Test 7

Verdict:

input
10 90

correct output
80

user output
90
80

Test 8

Verdict:

input
79 56

correct output
55

user output
46
55

Test 9

Verdict:

input
39 26

correct output
13

user output
26
13

Test 10

Verdict:

input
56 98

correct output
84

user output
56
97

Test 11

Verdict:

input
90 54

correct output
36

user output
36
36