topic:
input Output:
analysis:
What is required is the subject of the latter and n two decimal places, the results can be transformed into the following requirements:
but this time the presence of a / b in the above formula, certainly can not guarantee the accuracy of this time, and therefore to use the following alternative formulas:
So the beginning of the equation can be converted into the following formula:
At this point application of the above problems would not worry about accuracy problems, but this time direct calculation or time out, so this time we want to use to solve the rapid power
Code:
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
long long a,b,n,mod,ans;
long long QuickMul(long long x,long long y,long long MOD)
{
long long res = 1;
while(y)
{
if(y&1)
res = res * x % MOD;
x = x * x % MOD;
y = (y>>1);
}
return res;
}
int main()
{
scanf("%lld%lld%lld",&a,&b,&n);
mod = b*1000;
ans = (a % mod) * QuickMul(10,n+2,mod) % mod / b;
printf("%lld\n",ans);
return 0;
}