hdu2117: Just a Numble
hdu2117: http://acm.hdu.edu.cn/showproblem.php?pid=2117
题意:输入n和m(1<=n<=10^7,1<=m<=10^5),求1/n小数点后第m个数 解法:模拟除法。 code:
#include<iostream> #include<cstdio> #include<cstdlib> int main() { int m,n,s,x; while(scanf("%d%d",&n,&m)!=EOF) { s=1; for(int i=0;i<=m;i++) { x=s/n; s=(s%n)*10; } printf("%d\n",x); } } /*input: 4 2 5 7 123 123 output: 5 0 8 */