http://acm.hdu.edu.cn/showproblem.php?pid=2117

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
 
时间复杂度:$O(m)$
代码:

#include <bits/stdc++.h>
using namespace std; int main() {
int n, m, sum, k;
while(~scanf("%d%d", &n, &m)) {
sum = 1;
for(int i = 0; i < m; i ++) {
sum = sum * 10;
k = sum / n;
sum = sum % n;
}
printf("%d\n",k % 10);
}
return 0;
}

  

HDU 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. HDOJ 2117 Just a Numble(模拟除法)

    Problem Description Now give you two integers n m, you just tell me the m-th number after radix poin ...

  3. HDU 2117 取(2堆)石子游戏【wzf博弈】

    题意:威佐夫博弈原型,除了输出先手能不能胜,还要输出先手的第一手选择. 思路:预处理出1000000以内的所有奇异局势.对于每个自然数,其必然是某一个奇异局势的a或者b.故对于一个非奇异局势,必定有一 ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  6. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  7. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  8. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  9. hdu 1426(DFS+坑爹的输入输出)

    Sudoku Killer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

随机推荐

  1. sea.js模块化工具

    sea.js 一. sea.js向全局中引入了两个变量seajs.define: 1.seajs用加载文件 seajs.use(deps,callback)异步引入入口模块 路径要以sea.js文件所 ...

  2. 『Linux基础 - 1』计算机基础概念

    这篇笔记的知识点结构目录: 认识计算机: (1)什么是计算机; (2)计算机的发展过程 计算机的构成: (1) 计算机硬件系统; (2) 计算机软件系统 二进制: (1) 为什么用二进制 (2) 二进 ...

  3. 【面试必问】python实例方法、类方法@classmethod、静态方法@staticmethod和属性方法@property区别

    [面试必问]python实例方法.类方法@classmethod.静态方法@staticmethod和属性方法@property区别 1.#类方法@classmethod,只能访问类变量,不能访问实例 ...

  4. linux进程篇 (三) 进程间的通信3 IPC通信

    3 IPC通信 用户空间 进程A <----无法通信----> 进程B -----------------|--------------------------------------|- ...

  5. 4-c++教程起航篇-学习笔记

    c++教程起航篇 我们会讲C++那些事,C++与C语言的关系. C++诞生于贝尔实验室. C++之父: 本贾尼·斯特劳斯特卢普 C++社区排行榜 最新排行,c++排名第三,Python排名第四 C++ ...

  6. FPGA算法学习(1) -- Cordic(Verilog实现)

    上两篇博文Cordic算法--圆周系统之旋转模式.Cordic算法--圆周系统之向量模式做了理论分析和实现,但是所用到的变量依然是浮点型,而cordic真正的用处是基于FPGA等只能处理定点的平台.只 ...

  7. CodeChef BIBOARD: Binary Board 命题报告

    这道题当时有了一点模糊的想法之后,构思了一整天-- 题意: 有一\(N \times M\)网格,每一格可以是白色或黑色.令\(B_i\)表示\(i \times i\)的纯黑子网格数量(子网格是指原 ...

  8. 引用ZXing生成二维码

    1.生成二维码 ZXing是一个开放源码的,用Java实现的多种格式的1D/2D条码图像处理库,它包含了联系到其他语言的端口. Zxing可以实现使用手机的内置的摄像头完成条形码的扫描及解码.本文引用 ...

  9. 西安Uber优步司机奖励政策(12月21日-12.27日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  10. JS dataTables

    原文地址: http://www.cnblogs.com/haogj/archive/2011/03/04/1971328.html   数据来源有四种: 1. 网页DOM对象 $(document) ...