hdu2522
来源:互联网 发布:php手册 pdf 编辑:程序博客网 时间:2024/05/23 18:21
想一想你平时是怎么计算除法的。这个程序其实就是模拟除法的;
#include<iostream>#include<string.h>using namespace std;int hash[100003];int main(){ int n; cin>>n; while(n--) { int a; cin>>a; if(a==1) { cout<<1<<endl; } else { if(a<0) { cout<<'-'; a=-a; } cout<<"0."; int res=1; memset(hash,0,sizeof(hash)); hash[1]=1; while(res) { res=res*10; cout<<res/a; if(hash[res%a]) break; hash[res%a]=1; res=res%a; } cout<<endl; } }}
0 0
- hdu2522
- hdu2522
- HDU2522
- hdu2522
- hdu2522(数学)
- HDU2522:A simple problem
- hdu2522(hash)
- HDU2522 A simple problem 【模拟】
- hdu2522 A simple problem(数学)
- hdu2522 A simple problem(循环节)
- hdu2522 模拟除法 和 无限循环小数的判断
- HDU2522(分数化小数,简单的模拟)
- 好题——hdu2522(小数问题:求1/n的第一个循环节)
- Frames
- Codeforces 441 E. Valera and Number
- 结构化异常(SEH)简述
- 笔试面试中遇到的一些智力题总结和思考,欢迎补充和指正
- 容器学习三:LinkedHashMap源码分析
- hdu2522
- CSS四种模式
- 403 D. Beautiful Pairs of Numbers
- java反射技术-----破坏单例模式
- uva 10306 - e-Coins
- AIDL(2):通过传输复杂对象
- 451 E. Devu and Flowers
- Java深入集合--linkedHashMap
- 欧拉函数