HDOJ2117 Just a Numble
来源:互联网 发布:激光雷达 算法 编辑:程序博客网 时间:2024/06/05 06:13
Just a Numble
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3628 Accepted Submission(s): 1821
Problem Description
Now give you two integers n m, you just tell me the m-th number after radix point in 1/n,for example n=4,the first numble after point is 2,the second is 5,and all 0 followed
Input
Each line of input will contain a pair of integers for n and m(1<=n<=10^7,1<=m<=10^5)
Output
For each line of input, your program should print a numble on a line,according to the above rules
Sample Input
4 25 7123 123
Sample Output
508
这个题使用大数是会超时的。
应该使用模拟算法。
import java.util.Scanner;public class Main{private static Scanner scanner;public static void main(String[] args) {scanner = new Scanner(System.in);while (scanner.hasNext()) {int n = scanner.nextInt();int m = scanner.nextInt();int num = 1;int res = 0;for (int i = 0; i < m; i++) {if (num == 0) {//如果余数是0证明该数除尽了res = 0;//之后的都是0break;}num *= 10;//避免小数res = num / n;num %= n;}System.out.println(res%10);}}}
阅读全文
0 0
- HDOJ2117 Just a Numble
- Just a Numble
- Just a Numble
- Just a Numble
- hdu2117 Just a Numble
- HDU2117 Just a Numble
- Just a Numble 2117
- Just a Numble
- hdu 2117 Just a Numble
- hdu 2117 Just a Numble
- hdu 2117 Just a Numble
- hdu 2117 Just a Numble
- Just a Numble HDU 2117
- HDU 2117 Just a Numble
- hdu-2117-Just a Numble
- HUD-2117-Just a Numble
- HDOJ 2117 Just a Numble
- Just a Numble模拟除法的运算
- I2C总线协议
- 中英键盘按键说明
- 数论——整除
- 前端之微信小程序搜索
- 习题6.14
- HDOJ2117 Just a Numble
- HDU 1686-Oulipo
- 确定字符互异 确定一个字符串的所有字符是否全都不同。这里我们要求不允许使用额外的存储结构。 给定一个string iniString,请返回一个bool值,True代表所有字符全都不同,False代
- 杭电oj1031
- linux-基础练习
- jQuery弹出窗口插件LeanModal的使用方法
- CentOS6网络连接
- 计算1*2*3+3*4*5+.......+99*100*101的值
- 如何在浏览器上使用Octotree插件树形地展示Github项目代码?