# 赚钱买房（java大数+逆元+等比数列求和+快速幂）

#include<cstdio>
#include<cmath>
#include<iostream>
#define ll long long
using namespace std;
ll pow_mod(ll a,ll n,ll m)
{
ll ans = 1;
a = a % m;
while(n>0)
{
if(n%2 ==1)
ans=(ans*a)%m;
n=n/2;
a=(a*a) % m;
}
return ans;
}
int main()
{
ll a,n,b,sum1,sum2,i,sum3;
while(scanf("%lld%lld%lld",&a,&n,&b)!=EOF)
{
sum1=9*b;
cout<<"模式:"<<pow_mod(10,n,sum1)<<endl;
sum3=(pow_mod(10,n,sum1)-1%sum1)%sum1;
cout<<sum3<<endl;
sum2=((a%sum1)*(sum3%sum1))%sum1;
sum2/=9;
cout<<b-sum2<<endl;
}
}
/*
0 9999999 2147483646
5 9999999  456465465
2012456840 1000 3
2054879653 1000 546813
2147483646 0 54
4568 9999999 5687
68456213 9999999 2147483646
9999999 9999999 9999999

2147483646
109893150
1
230594
54
2219
326455227
9999999
*/
C++在运算过程中超了ll的值，所以我们需要重新想办法！

import java.math.BigInteger;
import java.util.Scanner;
import java.math.*;
public class Main {
public static void main(String[] args)
{
Scanner cin=new Scanner(System.in);
BigInteger sum2,a,b,sum1,sum3;
int n;
while (cin.hasNext())
{
a=cin.nextBigInteger();
n=cin.nextInt();
b=cin.nextBigInteger();
sum1=BigInteger.valueOf(9).multiply(b);
sum3=(pow_mod(BigInteger.valueOf(10),n,sum1).subtract((BigInteger.valueOf(1).remainder(sum1)))).remainder(sum1);
sum2=((a.remainder(sum1)).multiply(sum3.remainder(sum1))).remainder(sum1);
sum2=sum2.divide(BigInteger.valueOf(9));
System.out.println(b.subtract(sum2));
}

}
private static  BigInteger pow_mod(BigInteger a, int n,BigInteger m)
{
BigInteger ans = BigInteger.valueOf(1);
a = a.remainder(m);
while(n>0)
{
if(n%2 ==1)
ans=(ans.multiply(a)).remainder(m);
n=n/2;
a=a.multiply(a).remainder(m);
}
return ans;

}
}

ok！呵呵！

04-16 20

06-14 260

10-11 192

03-12 373

04-09 57

10-02 1609

07-30 786

08-08 2120

08-17 650

05-10 358