
This simple puzzle is from Timus Online Judge.
Despite a lengthy description, the solution is really simple. The number of lines is the number of the seconds he needs to write it. There are two variables, the second number N starts with index 0, and the first variable M starts with index 1, so the total number is M * (N + 1)
#include <iostream>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
cout << n * (m + 1) << endl;
return (0);
}
Believe your eyes, it is that simple with algorithm complexity
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Tutorial - 7 - C Programming in 6502 - Colour Setting for NES
Next Post: Why Absolute Value of INT_MAX and INT_MIN is different?