Round and Round We Go
--------------------------------------------------------------------------------
Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 1293 Accepted Submit: 630
--------------------------------------------------------------------------------
Problem
A cyclic number is an integer n digits in length which, when multiplied by any integer from 1 to n, yields a “cycle” of the digits of the original number. That is, if you consider the number after the last digit to “wrap around” back to the first digit, the sequence of digits in both numbers will be the same, though they may start at different positions.
For example, the number 142857 is cyclic, as illustrated by the following table:
142857 * 1 = 142857
142857 * 2 = 285714
142857 * 3 = 428571
142857 * 4 = 571428
142857 * 5 = 714285
142857 * 6 = 857142
Write a program which will determine whether or not numbers are cyclic. The input file is a list of integers from 2 to 60 digits in length. (Note that preceding zeros should not be removed, they are considered part of the number and count in determining n. Thus, “01” is a two-digit number, distinct from “1” which is a one-digit number.)
Output
For each input integer, write a line in the output indicating whether or not it is cyclic.
Example
Input
142857
142856
142858
01
0588235294117647
Output
142857 is cyclic
142856 is not cyclic
142858 is not cyclic
01 is not cyclic
0588235294117647 is cyclic
/*看给出的例子应该可以看得懂.*/
----------------解决方案--------------------------------------------------------
Martian Addition
--------------------------------------------------------------------------------
Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 3228 Accepted Submit: 1090
--------------------------------------------------------------------------------
In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on Mars (ACM). The task of the contest is to calculate the sum of two 100-digit numbers, and the winner is the one who uses least time. This year they also invite people on Earth to join the contest.
As the only delegate of Earth, you're sent to Mars to demonstrate the power of mankind. Fortunately you have taken your laptop computer with you which can help you do the job quickly. Now the remaining problem is only to write a short program to calculate the sum of 2 given numbers. However, before you begin to program, you remember that the Martians use a 20-based number system as they usually have 20 fingers.
Input:
You're given several pairs of Martian numbers, each number on a line.
Martian number consists of digits from 0 to 9, and lower case letters from a to j (lower case letters starting from a to present 10, 11, ..., 19).
The length of the given number is never greater than 100.
Output:
For each pair of numbers, write the sum of the 2 numbers in a single line.
Sample Input:
1234567890
abcdefghij
99999jjjjj
9999900001
Sample Output:
bdfi02467j
iiiij00000
/*20进制大数的加法,只要细心,就可以做的出来.*/
----------------解决方案--------------------------------------------------------
哈哈。今天我第1个。HOHO~不过这几天要做网页。先收下题目咯!耶耶!
----------------解决方案--------------------------------------------------------
第二题:
#include "stdio.h"
int main(void) {
char a[100]={0},b[100]={0},sum[100]={0};
int i=0,lena,lenb,f=99;
scanf("%s%s",a,b);
while(a[i]!=0) {
if(a[i]<58) a[i]-='0'; else a[i]-=87;
i++;
}
lena=i;
i=0;
while(b[i]!=0) {
if(b[i]<58) b[i]-='0'; else b[i]-=87;
i++;
}
lenb=i;
i=1;
while(lena!=0 || lenb!=0 || i) {
if(lena==0 && lenb==0) i=0;
sum[f]=a[lena]+b[lenb];
f--;
if(lena==0) a[lena]=0; else lena--;
if(lenb==0) b[lenb]=0; else lenb--;
}
for(f=99;f>-1;f--) {
sum[f-1]+=sum[f]/20;
sum[f]=sum[f]%20;
}
f=0;
for(i=0;i<99;i++) {
if(f==0 && sum[i]!=0) f=1;
if(f) if(sum[i]<10) printf("%d",sum[i]); else printf("%c",sum[i]+87);
}
return 0;
}
----------------解决方案--------------------------------------------------------
第一题应该有规律,只是不好找
...偶不想做高精度来计算,想走捷径.....再仔细看看,明天在做
[此贴子已经被作者于2006-11-26 21:05:44编辑过]
----------------解决方案--------------------------------------------------------
是有规律:
142857
142+857=999;
05882352+94117647=99999999
----------------解决方案--------------------------------------------------------
是有规律:
142857
142+857=999;
05882352+94117647=99999999
----------------解决方案--------------------------------------------------------
给个循环节表:
1/2=0.5
1/3=0.(3)
1/4=0.25
1/5=0.2
1/6=0.1(6)
1/7=0.(142857)
1/8=0.125
1/9=0.(1)
1/10=0.1
1/11=0.(09)
1/12=0.08(3)
1/13=0.(076923)
1/14=0.0(714285)
1/15=0.0(6)
1/16=0.0625
1/17=0.(0588235294117647)
1/18=0.0(5)
1/19=0.(052631578947368421)
1/20=0.05
1/21=0.(047619)
1/22=0.0(45)
1/23=0.(0434782608695652173913)
1/24=0.041(6)
1/25=0.04
1/26=0.0(384615)
1/27=0.(037)
1/28=0.03(571428)
1/29=0.(0344827586206896551724137931)
1/30=0.0(3)
1/31=0.(032258064516129)
1/32=0.03125
1/33=0.(03)
1/34=0.0(2941176470588235)
1/35=0.0(285714)
1/36=0.02(7)
1/37=0.(027)
1/38=0.0(263157894736842105)
1/39=0.(025641)
1/40=0.025
1/41=0.(02439)
1/42=0.0(238095)
1/43=0.(023255813953488372093)
1/44=0.02(27)
1/45=0.0(2)
1/46=0.0(2173913043478260869565)
1/47=0.(0212765957446808510638297872340425531914893617)
1/48=0.0208(3)
1/49=0.(020408163265306122448979591836734693877551)
1/50=0.02
1/51=0.(0196078431372549)
1/52=0.01(923076)
1/53=0.(0188679245283)
1/54=0.0(185)
1/55=0.0(18)
1/56=0.017(857142)
1/57=0.(017543859649122807)
1/58=0.0(1724137931034482758620689655)
1/59=0.(0169491525423728813559322033898305084745762711864406779661)
1/60=0.01(6)
1/61=0.(016393442622950819672131147540983606557377049180327868852459)
1/62=0.0(161290322580645)
1/63=0.(015873)
1/64=0.015625
1/65=0.0(153846)
1/66=0.0(15)
1/67=0.(014925373134328358208955223880597)
1/68=0.01(4705882352941176)
1/69=0.(0144927536231884057971)
1/70=0.0(142857)
1/71=0.(01408450704225352112676056338028169)
1/72=0.013(8)
1/73=0.(01369863)
1/74=0.0(135)
1/75=0.01(3)
1/76=0.01(315789473684210526)
1/77=0.(012987)
1/78=0.0(128205)
1/79=0.(0126582278481)
1/80=0.0125
Press any key to continue
----------------解决方案--------------------------------------------------------
我觉得规律是:
142857 * 7 = 999999
052631578947368421 * 19 = 999999999999999999
0434782608695652173913 * 23 = 9999999999999999999999
也即
序列 * (序列长度 + 1) = 9999....999
----------------解决方案--------------------------------------------------------
这应是一个很有名的问题:关于循环节的,实际上只要找到这些数作除数,(这些数满足其除后循环节分成两半,相加后都是所有为都是9)
比如1/7的循环节是142857,142+857=999
而2/7的循环节是 285714,285+714=999
继续下去其实就是1,4,2,8,5,7的排列
我想应该是找到这些除数就可以了,不过这种数还要满足(除数)还要满足: 循环节=除数-1
我认为2到20位的满足条件的就三个 7,17,19,分别对应142857,0588235294117647,052631578947368421
如果找原因,我不知道,我看到这个东西的时候还没人证明出来,离现在大概有10年左右了吧
----------------解决方案--------------------------------------------------------