CF468C 【Hack it!】

Construction issues really are very fairy ah

First, a problem translation, \ (L, R & lt \) range should be \ ([1, 10 ^ {200}] \)

Because the modulus reaches a \ (10 ^ {18} \) , so we can see that, when the \ (i <10 ^ {18 } \) when, \ (F () \) has a property:

\[ f(i+10^{18}) = f(i)+1\]

We make \ (g = \ sum_ {i = 1} ^ {10 ^ {18}} f (i) \ (mod \ a) \)

So we have: \ (. 1 + G = \ sum_ {I} = ^ 2 ^ {10} {18 is F + 1'd} (I) \ (MOD \ A) \)

\(g+a-g=\sum_{i=a-g+1}^{10^{18}+a-g}f(i)\ (mod\ a)=0\ (mod\ a)\)

Therefore, we can construct a set of solutions for the \ ([ag, 10 ^ { 18} + ag + 1] \)

So we find now the question becomes \ (g \)

\(g=\sum_{i=1}^{10^{18}-1}f(i)+1\)

For \ (10 ^ {18} -1 \) of the number of occurrences of all the digits are the same length

So the answer should be \ (45 * \) each digit appears many times

This thing can be usedDigital DPThe number of combinations to find: the original problem as we imagine: there are 18 vacancies, you can put \ ([0, 9] \) all the numbers, ask \ (i \) put the number of times

\ [ans = \ sum_ {i
= 1} ^ {18} C_ {18} ^ i * 9 ^ {18-i} \] followed by \ (__ int128 \) running about, the answer is \ (45 * 18 * 10 ^ {17} + 1 = 81 * 10 ^ {18} + 1 \)

\(Code:\)

#include<bits/stdc++.h>
using namespace std;
long long a, pax = 1e18 + 1;
signed main() {
    cin >> a;
    long long l = a - pax % a * 9 % a * 9 % a, r = pax + l - 1;
    printf("%lld %lld", l, r);
    return 0;
}

Guess you like

Origin www.cnblogs.com/bcoier/p/11774604.html