Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1 group + 6 points XD https://informatics.mccme.ru/mod/statements/view3.php?id=18806&chapterid=113102#1
- # include <iostream>
- # include <vector>
- using namespace std;
- const uint64_t MOD = 1000000007;
- int main() {
- uint64_t l, r;
- cin >> l >> r;
- uint64_t i = l;
- uint64_t count = 0;
- while (i <= r) {
- uint64_t new_i = i;
- if ((i >= 10 && i % 10 < (i % 100) / 10) || i % 10 == 0) {
- new_i = 0;
- vector<int8_t> copy;
- while (i > 9) {
- copy.push_back(i % 10);
- i /= 10;
- }
- copy.push_back(i);
- for (size_t j = copy.size() - 2; (j + 1) > j; j--) {
- if (copy[j] < copy[j + 1]) {
- copy[j] = copy[j + 1];
- }
- }
- for (size_t j = copy.size() - 1; (j + 1) > j; j--) {
- new_i = new_i * 10 + copy[j];
- }
- }
- if (new_i >= l && new_i <= r) {
- count++;
- }
- i = new_i + 1;
- }
- cout << count % MOD;
- return 0;
- }
Add Comment
Please, Sign In to add comment