十进制的分数转化为七进制的小数
来源:互联网 发布:网络聊天语言 编辑:程序博客网 时间:2024/04/29 14:54
F - Consecutive Digits
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %lluDescription
As a recruiting ploy, Google once posted billboards in Harvard Square and in the Silicon Valley area just stating “{first 10-digit prime found in consecutive digits of e}.com”. In other words, find that 10-digit sequence and then connect to the web site — and find out that Google is trying to hire people who can solve a particular kind of problem.
Not to be outdone, Gaggle (a loosy-goosy fuzzy logic search firm), has devised its own recruiting problem. Consider the base 7 expansion of a rational number. For example, the first few digits of the base 7 expansion of 1/5 10 = 0.12541... 7, 33/4 10 = 11.15151... 7, and 6/49 10 = 0.06000... 7, From this expansion, find the digits in a particular range of positions to the right of the "decimal" point.
Not to be outdone, Gaggle (a loosy-goosy fuzzy logic search firm), has devised its own recruiting problem. Consider the base 7 expansion of a rational number. For example, the first few digits of the base 7 expansion of 1/5 10 = 0.12541... 7, 33/4 10 = 11.15151... 7, and 6/49 10 = 0.06000... 7, From this expansion, find the digits in a particular range of positions to the right of the "decimal" point.
Input
The input file begins with a line containing a single integer specifying the number of problem sets in the file. Each problem set is specified by four base 10 numbers on a single line, n d b e, where n and d are the numerator and denominator of the rational number and 0 <= n <= 5,000 and 1 <= d <= 5,000. b and e are the beginning and ending positions for the desired range of digits, with 0 <= b,e <= 250 and 0 <= (e-b) <= 20. Note that 0 is the position immediately to the right of the decimal point.
Output
Each problem set will be numbered (beginning at one) and will generate a single line:
where k is replaced by the problem set number, result is your computed result, and the other values are the corresponding input values.
- Problem set k: n / d, base 7 digits b through e: result
where k is replaced by the problem set number, result is your computed result, and the other values are the corresponding input values.
Sample Input
41 5 0 06 49 1 333 4 2 7511 977 122 126
Sample Output
Problem set 1: 1 / 5, base 7 digits 0 through 0: 1Problem set 2: 6 / 49, base 7 digits 1 through 3: 600Problem set 3: 33 / 4, base 7 digits 2 through 7: 151515Problem set 4: 511 / 977, base 7 digits 122 through 126: 12425
#include<iostream> #include<cmath> #include<algorithm> #include<string>#include<cstring>#include<cstdlib>#define MAX 255#include<stack>#include<cstdio>using namespace std; int main(){int T,n,d,b,e;cin>>T;for(int i=1;i<=T;i++){cin>>n>>d>>b>>e;printf("Problem set %d: %d / %d, base 7 digits %d through %d: ",i,n,d,b,e);n%=d;for(int j=0;j<=e;j++){n*=7;if(j>=b)printf("%d",n/d);n%=d;}cout<<endl;}return 0;}
0 0
- 十进制的分数转化为七进制的小数
- 小数转化为分数
- 分数转化为小数
- 分数转化为小数
- 十进制小数转化为其他进制的
- 十进制小数分数与二进制的转换
- 八进制小数转化为十进制小数
- 将十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 转:十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 十进制小数转化为二进制小数
- 转:十进制小数转化为二进制小数
- 单机最大tcp连接数
- 盛大游戏 C++ 视频面试 面经
- 目标跟踪总结
- Android中View的setClickable,setEnable,setFocusable区别
- Toast的正确打开方式——Toast多次显示不消失——toast显示问题
- 十进制的分数转化为七进制的小数
- 对拍程序
- 国产网管软件的深化发展之路
- foreach循环
- Spring注入
- sf4j-log4j日志系统搭建
- 微信公众号开发之获取微信用户的openID
- AIDL -- 小白学习笔记1
- jquery div 下拉框焦点事件