首页 > 代码库 > Codeforces 468C Hack it!(数学)

Codeforces 468C Hack it!(数学)

题目链接:Codeforces 468C Hack it!

题目大意:给据题目定义,找到l,r,使得solve(l,r) % a = 0.

解题思路:f(x + 1e18) = f(x) + 1,所以有solve(x + 1, x+1e18) = solve(x, x+1e18-1) + 1,假定x为0,我们求出solve(0, 1e18) % a = k,那么a - k,即为区间需要移动的步长。solve(1e18) % a = 45181e17 % a

#include <cstdio>
#include <cstring>
#include <algorithm>

using  namespace std;
typedef long long ll;

ll A, M = 1e17;

int main () {
    scanf("%lld", &A);
    A -= 5 * (9 * (M * 18 % A) % A) % A;
    printf("%lld %lld\n", A, A + M * 10 - 1);
    return 0;
}

Codeforces 468C Hack it!(数学)