标签:style http color io os ar for sp on
题目大意:给据题目定义,找到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 = 4518 1e17 % 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;
}
标签:style http color io os ar for sp on
原文地址:http://blog.csdn.net/keshuai19940722/article/details/39528899