Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Created June 4, 2017 16:55
Show Gist options
  • Save MohamedTaha98/bae07e93d456639d4e1a8dcd88677cf4 to your computer and use it in GitHub Desktop.
Save MohamedTaha98/bae07e93d456639d4e1a8dcd88677cf4 to your computer and use it in GitHub Desktop.
Problem Solving
#include <iostream>
using namespace std;
int main() {
long n, m, a, flagstones;
cin >> n >> m >> a;
if (n % a == 0 && m % a == 0)
flagstones = (n / a) * (m / a);
else if (n % a != 0 && m % a == 0)
flagstones = ((n / a) + 1) * (m / a);
else if (n % a == 0 && m % a != 0)
flagstones = (n / a) * ((m / a) + 1);
else
flagstones = ((n / a) + 1) * ((m / a) + 1);
cout << flagstones << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment