hdu 2117(小数点后m位)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2117

题意:问1/n的小数点后第m位是多少。高精度除法。

直接上代码了:

View Code
 1 #include<iostream>
 2 using namespace std;
 3 
 4 int solve(int n,int m){
 5     int divided=1,res=0;
 6     for(int i=0;i<=m;i++){
 7         res=divided/n;
 8         divided=10*(divided%n);
 9     }
10     return res;
11 }
12 
13 
14 int main(){
15     int n,m;
16     while(~scanf("%d%d",&n,&m)){
17         printf("%d\n",solve(n,m));
18     }
19     return 0;
20 }
原文地址:https://www.cnblogs.com/wally/p/2966729.html