/*
题意:输入n、m,设a=1/n,输出a小数点后第m位的值
思路:模拟除法实现
*/
#include <cstdio>
#include <cstring>
const int mMax=100007;
int res[mMax],e;
int n,m;
void solve()
{
memset(res,0,sizeof(res));
e=0;
int k=1;
while(k != 0 && e < m)
{
k *= 10;
if(k >= n)
{
res[e++] = k / n;
k = k % n;
}
else
res[e++]=0;
}
}
int main()
{
//freopen("f://data.in","r",stdin);
while(scanf("%d %d", &n, &m) != EOF)
{
if(n == 1) printf("0\n");
else
{
solve();
printf("%d\n",res[m-1]);
}
}
return 0;
}
hdu 2117 Just a Numble
最新推荐文章于 2018-06-19 19:22:36 发布