1 #include <stdio.h> 2 #include <stdlib.h> 3 typedef long long ll; 4 5 int main() 6 { 7 ll x=1e17; 8 ll y=1e18; 9 ll a,b; 10 scanf("%lld",&a); 11 //long long 范围 <大约为9.2*10^18 (2^63) 12 //x=1e17 13 //1<=a<=10^18 14 ///所以 b=((5*(x*9%a))%a*18)%a; 是不对的,中间运算结构xx*10^18已超出整形范围(2^63) 15 ///1~10^18-1 b 16 ///1~10^18 b+1 17 ///k~10^18+k-1 b+k(=a) 18 b=((x*18*5)%a*9)%a; 19 printf("%lld %lld\n",a-b,y+a-b-1); 20 21 return 0; 22 }
时间: 2024-10-16 16:53:10