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 2

5 7

123 123

Sample Output

5

0

8

开始想用JAVA的大数做的,可是超时了。。。

所以只有走上算法的路,用了模拟。

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
int m = sc.nextInt();
int sum = 1;
int t=0;
for(int i=0;i<m;i++){
if(sum==0){
t=0;
break;
}
sum = sum*10;
t = sum/n;
sum = sum%n; }
System.out.println(t%10);
} } }

HDOJ 2117 Just a Numble(模拟除法)的更多相关文章

  1. hdu 2117:Just a Numble(水题,模拟除法运算)

    Just a Numble Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  2. PTA——模拟除法

    PTA 7-42 整除光棍 #include <stdio.h> int main() { ];//创建存表 ,count=; int n; ; scanf("%d", ...

  3. PAT 天梯赛 L1-046. 整除光棍 【模拟除法】

    题目链接 https://www.patest.cn/contests/gplt/L1-046 思路 用同余定理以及模拟除法. AC代码 #include <iostream> #incl ...

  4. HDU 2117 Just a Numble

    http://acm.hdu.edu.cn/showproblem.php?pid=2117 Problem Description Now give you two integers n m, yo ...

  5. PAT 团体程序设计天梯赛 L1-046 整除光棍(模拟除法)

    L1-046. 整除光棍 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 翁恺 这里所谓的"光棍",并不是指单身汪 ...

  6. HDOJ 5402 Travelling Salesman Problem 模拟

    行数或列数为奇数就能够所有走完. 行数和列数都是偶数,能够选择空出一个(x+y)为奇数的点. 假设要空出一个(x+y)为偶数的点,则必须空出其它(x+y)为奇数的点 Travelling Salesm ...

  7. HDOJ 5414 CRB and String 模拟

    CRB and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) T ...

  8. Gym-100814K 数位DP 模拟除法

    Johnny is a brilliant mathematics student. He loves mathematics since he was a child, now he is work ...

  9. L1-046. 整除光棍(模拟除法)

    题意: 这里所谓的“光棍”,并不是指单身汪啦~ 说的是全部由1组成的数字,比如1.11.111.1111等.传说任何一个光棍都能被一个不以5结尾的奇数整除.比如,111111就可以被13整除. 现在, ...

随机推荐

  1. 在Qt中使用sleep

      关于sleep函数,我们先来看一下他的作用:sleep函数是使调用sleep函数的线程休眠,线程主动放弃时间片.当经过指定的时间间隔后,再启动线程,继续执行代码.sleep函数并不能起到定时的作用 ...

  2. 使用 Java 配置进行 Spring bean 管理--转

    概述 众所周知,Spring 框架是控制反转 (IOC) 或依赖性注入 (DI) 模式的推动因素,而这种推动是通过基于容器的配置实现的.过去,Spring 允许开发人员使用基于 XML 的配置,通过利 ...

  3. C#之—委托

    (1)定义委托:(百度百科样例,只有写了才有收获) namespace Entrust { public delegate void GreetingDelegate(string name); // ...

  4. CSS基本知识介绍

    CSS (Cascading Style Sheet)叠层样式表.用于控制网页样式并允许将样式信息与网页内容分离的一种标记性语言. 样式的几种控制方法: 1.行内样式         <div ...

  5. 关于asp.net程序连接不了ORACLE数据库而PL/SQL可以连接的问题

    今天在发布ASP.NET WEB网站时发现程序连接不了数据 报“ORA-12154: TNS: 无法解析指定的连接标识符”的错误,但PL/SQL连接又没有问题.真莫名其秒.在百度找了好多相关的问题.都 ...

  6. System.Web.HttpContext.Current.Session获取值出错

    在自定义类库CS文件里使用System.Web.HttpContext.Current.Session获取Session时提示错误:未将对象引用设置到对象的实例. 一般情况下通过这种方式获取Sessi ...

  7. nodejs新手教程中upload file的问题

    可参见: http://cnodejs.org/topic/50234890f767cc9a51f88481 request.setEncoding("utf8");应注释掉.

  8. ExtJS智能提示工具spket安装与破解

    用myeclipse写java程序,最怕的是什么呢,写javascript代码,原因很简单,没有智能提示,ExtJS是完全js代码的界面库,写起来就更痛苦了,幸好有人做了spket插件,此文采用傻瓜式 ...

  9. 解决 Ubuntu15.04 登陆界面无限循环 的问题

    本人新手,在学习linux 安装NVIDIA 驱动的时候出现了一个奇怪的问题:登陆界面输入正确的账户密码,短暂闪烁后又返回了登陆界面.经查阅多种资料,已解决此问题 以下内容来自:http://blog ...

  10. ext之关键字mixins、statics、require

    1.mixins 说明:类似于面向对象中的多继承 <script type="text/javascript"> Ext.onReady(function () { / ...