From f1f1f52eb24ad0a6efcc5ccd21e6b65a58063992 Mon Sep 17 00:00:00 2001 From: ayham Date: Sun, 9 May 2021 18:51:07 +0300 Subject: [PATCH] solved beautiful days at the movies Signed-off-by: ayham --- hackerrank.beautiful.days.at.the.movies.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 hackerrank.beautiful.days.at.the.movies.cpp diff --git a/hackerrank.beautiful.days.at.the.movies.cpp b/hackerrank.beautiful.days.at.the.movies.cpp new file mode 100644 index 0000000..199859a --- /dev/null +++ b/hackerrank.beautiful.days.at.the.movies.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; + +int reverse(int num) { + string tmp = to_string(num); + reverse(tmp.begin(), tmp.end()); + return stoi(tmp); +} + +int main() { + int i, j, k, res = 0; + cin >> i >> j >> k; + for (; i <= j; i++) + if (abs(i-reverse(i)) % k == 0) res++; + cout << res << endl; + return 0; +}