Integer Inquiry
来源:互联网 发布:用友通软件 编辑:程序博客网 时间:2024/05/22 17:26
E - Integer Inquiry
Crawling in process...Crawling failedTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%lld & %lluSubmit
Description
Input
Output
Sample Input
Sample Output
Hint
Description
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/510 = 0.12541... 7, 33/4 10 = 11.15151... 7, and 6/4910 = 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/510 = 0.12541... 7, 33/4 10 = 11.15151... 7, and 6/4910 = 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
Hint
Description
One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.
``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)
``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these results.'' (Chip moved to a new apartment, once one became available on the third floor of the Lemon Sky apartments on Third Street.)
Input
The input will consist of at most 100 lines of text, each of which contains a single VeryLongInteger. Each VeryLongInteger will be 100 or fewer characters in length, and will only contain digits (no VeryLongInteger will be negative).
The final input line will contain a single zero on a line by itself.
The final input line will contain a single zero on a line by itself.
Output
Your program should output the sum of the VeryLongIntegers given in the input.
Sample Input
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900
Sample Output
370370367037037036703703703670
#include<stdio.h>#include<string.h>#define N 103char capten[N];char temp[N];void shift(char *a);int main(){int carry,i;char tp;memset(capten,'0',sizeof(capten));/*for(i=0;i<N;i++)printf("%c",capten[i]);printf("\n");*/while(gets(temp) && (strlen(temp)!=1 || temp[0]!='0')){carry=0;shift(temp);/*for(i=0;i<N;i++)printf("%c",temp[i]);printf("\n");*/for(i=N-1;i>=0;i--){tp=capten[i];capten[i]= (carry+(capten[i]-'0')+(temp[i]-'0')) % 10 +'0';carry= (carry+(tp-'0')+(temp[i]-'0'))/10;}}for(i=0;;i++)if(capten[i] != '0')break;for(i;i<N;i++)printf("%c",capten[i]);printf("\n");return 0;}void shift(char *a){int len=strlen(a);int k=len-1;int i;int gap=N-len;for(k;k>=0;k--){a[k+gap]=a[k];}for(i=0;i<gap;i++){a[i]='0';}}
0 0
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- POJ – 1503 Integer Inquiry Integer Inquiry
- 1503 Integer Inquiry
- HDU1047 Integer Inquiry
- centos6.5 搭建 mysql5.7.15
- 开博第一篇必须水!
- AIX上静默安装WAS8.5.5.x的记录及思考
- leetcode--34--二分查找范围
- Markdown编辑器语法-格式设置
- Integer Inquiry
- (一)、一步一步学GTK+之开篇
- Java如何实现文件拷贝操作和如何正确关闭资源
- 计数排序
- Struts2笔记(持续更新)
- [Memcached系列]专题一:快速入门
- js学习笔记(四)表单验证
- Struts2学习——0200struts.xml初步解释
- 不同IO流对文本文件拷贝速度大小的比较