Algorithm


Problem Name: beecrowd | 3091

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3091

Rest 1.0

 

By Ygor Ribeiro, IFSULDEMINAS BR Brazil

Timelimit: 1

John is a math student, but few people know that. One day, one of his classmates, thinking that John did not know basic math concepts, challenged him to perform a simple calculation which was: Calculate the rest of the division of A ÷ B.

Since John is very shy and you are best friends, he informed you what the answer to the problem was and asked you to pass this information on to this colleague who challenged him. You can do it ?

Given two integers A and B, tell what is the rest of division of A ÷ B John passed you.

 

Input

 

The input contains two integers A and B (1 <= A, B <= 100000).

 

Output

 

The output contains one unique integer that is the rest of division of A ÷ B.

 

 

 

Input Samples Output Samples

8
3    

2

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
using namespace std;
int main()
{
    int a , b , x;
    cin >>a >> b;
    x = a%b;
    cout << x << endl;
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 3

Output

x
+
cmd
2

#2 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")
const [dividend, divisor] = readFileSync("/dev/stdin", "utf8")
	.split("\n", 2)
	.map(num => Number.parseInt(num, 10))

console.log(dividend % divisor)
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 3

Output

x
+
cmd
2

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const A = parseInt(lines.shift());
const B = parseInt(lines.shift());

console.log(`${A % B}`);
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 3

Output

x
+
cmd
2

#4 Code Example with Python Programming

Code - Python Programming


a = int(input())
b = int(input())

print(a%b)
Copy The Code & Try With Live Editor

Input

x
+
cmd
8 3

Output

x
+
cmd
2
Advertisements

Demonstration


Previous
#3084 Beecrowd Online Judge Solution 3084 Old Clock Solution in C, C++, Java, Js and Python
Next
#3140 Beecrowd Online Judge Solution 3140 Copying and Pasting Code Solution in C, C++, Java, Js and Python