Select solution language
In C++, when working with the int
data type, division will automatically truncate, which means to remove the decimal part of the answer. So actually, all we need to do is print ab, and we will get our answer!
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1E9 + 7;
const int INF = 1E9; const ll INFLL = 1E18;
int A; int B;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> A >> B;
cout << A / B << "\n";
}
Take A and B then print A / B
NOTE: In C++, you do not need to truncate the result, since A and B are already integers, and when 2 integers divides each other, C++ returns an integer. However, you must do so in Python because Python will return a decimal, even if B is divisible by A
#include <iostream>
using namespace std;
int main()
{
int A, B; cin >> A >> B;
cout << A + B;
}
inp = input().split()
A, B = int(inp[0]), int(inp[1])
print(A // B)
# By using "//" instead of "/", Python will return a truncated result instead