Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //URL FOR THE TASK: https://judge.softuni.bg/Contests/Practice/Index/540#5
- #include <iostream>
- using namespace std;
- int main()
- {
- int m;
- int n;
- int l;
- int special_num;
- int control_num;
- cin >> m >> n >> l >> special_num >> control_num;
- for (int i = m; i >= 1; --i)
- {
- for (int k = n; k >= 1; --k)
- {
- for (int j = l; j >= 1; --j)
- {
- int total_num = i * 100 + k * 10 + j;
- if (total_num % 3 == 0)
- {
- special_num += 5;
- }
- else if (total_num % 10 == 5)
- {
- special_num -= 2;
- }
- else if (total_num % 2 == 0)
- {
- special_num *= 2;
- }
- if (special_num >= control_num)
- {
- break;
- }
- }
- if (special_num >= control_num)
- {
- break;
- }
- }
- if (special_num >= control_num)
- {
- break;
- }
- }
- if (special_num >= control_num)
- {
- cout << "Yes! Control number was reached! Current special number is "
- << special_num << "."
- << endl;
- }
- else
- {
- cout << "No! "
- << special_num
- << " is the last reached special number."
- << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement