呵呵,谢了。
这个问题很有意思,所以昨晚(应该是今天凌晨)睡前还有脑子里琢磨。于是形成了下面这段代码。
算法本质还是我上面分析的,只是不过利用一点数论知识进行了优化,并将输出与大数运算的过程融合在一起省去了中间计算的缓存部分,将空间复杂度降到了最低。
实际运算速度比我预想的好很多,我的电脑是联想Y470。这段代码的运行时间是4632毫秒。
输出结果有21M之多,这里只摘了前面的一段给大家。有兴趣的可以编译执行一下我的代码,将输出重定向到文件看看所有的结果。
105263157894736842
157894736842105263
210526315789473684
263157894736842105
315789473684210526
368421052631578947
421052631578947368
473684210526315789
105263157894736842105263157894736842
157894736842105263157894736842105263
210526315789473684210526315789473684
263157894736842105263157894736842105
315789473684210526315789473684210526
368421052631578947368421052631578947
421052631578947368421052631578947368
473684210526315789473684210526315789
105263157894736842105263157894736842105263157894736842
157894736842105263157894736842105263157894736842105263
210526315789473684210526315789473684210526315789473684
263157894736842105263157894736842105263157894736842105
315789473684210526315789473684210526315789473684210526
368421052631578947368421052631578947368421052631578947
421052631578947368421052631578947368421052631578947368
473684210526315789473684210526315789473684210526315789
105263157894736842105263157894736842105263157894736842105263157894736842
157894736842105263157894736842105263157894736842105263157894736842105263
210526315789473684210526315789473684210526315789473684210526315789473684
263157894736842105263157894736842105263157894736842105263157894736842105
315789473684210526315789473684210526315789473684210526315789473684210526
368421052631578947368421052631578947368421052631578947368421052631578947
421052631578947368421052631578947368421052631578947368421052631578947368
473684210526315789473684210526315789473684210526315789473684210526315789
这个问题很有意思,所以昨晚(应该是今天凌晨)睡前还有脑子里琢磨。于是形成了下面这段代码。
算法本质还是我上面分析的,只是不过利用一点数论知识进行了优化,并将输出与大数运算的过程融合在一起省去了中间计算的缓存部分,将空间复杂度降到了最低。
实际运算速度比我预想的好很多,我的电脑是联想Y470。这段代码的运行时间是4632毫秒。
程序代码:
#include<stdio.h> int main() { int a, b, c, i, j; for(c = i = 1; i < 10000; i++) if((c = c * 10 % 19) == 2) for(b = 2; b <= 9; printf("%d\n", b++)) for(a = b * 10, j = 0; j < i; j++, a = a % 19 * 10) printf("%d", a / 19); return 0; }
输出结果有21M之多,这里只摘了前面的一段给大家。有兴趣的可以编译执行一下我的代码,将输出重定向到文件看看所有的结果。
105263157894736842
157894736842105263
210526315789473684
263157894736842105
315789473684210526
368421052631578947
421052631578947368
473684210526315789
105263157894736842105263157894736842
157894736842105263157894736842105263
210526315789473684210526315789473684
263157894736842105263157894736842105
315789473684210526315789473684210526
368421052631578947368421052631578947
421052631578947368421052631578947368
473684210526315789473684210526315789
105263157894736842105263157894736842105263157894736842
157894736842105263157894736842105263157894736842105263
210526315789473684210526315789473684210526315789473684
263157894736842105263157894736842105263157894736842105
315789473684210526315789473684210526315789473684210526
368421052631578947368421052631578947368421052631578947
421052631578947368421052631578947368421052631578947368
473684210526315789473684210526315789473684210526315789
105263157894736842105263157894736842105263157894736842105263157894736842
157894736842105263157894736842105263157894736842105263157894736842105263
210526315789473684210526315789473684210526315789473684210526315789473684
263157894736842105263157894736842105263157894736842105263157894736842105
315789473684210526315789473684210526315789473684210526315789473684210526
368421052631578947368421052631578947368421052631578947368421052631578947
421052631578947368421052631578947368421052631578947368421052631578947368
473684210526315789473684210526315789473684210526315789473684210526315789
重剑无锋,大巧不工