C++
文章平均质量分 55
ColorlessBoy
这个作者很懒,什么都没留下…
展开
-
Section 1.4-ariprog
problem: take too much time /* ID: penglin3 PROG: ariprog LANG: C++11 */ #include//sort 所在头文件,sort是C++的快排函数比qsort好用 #include #include #include using namespace std; struct arithprog { int a; int b原创 2016-07-04 09:49:02 · 207 阅读 · 0 评论 -
section 1.4 milk3
首次做的错误-首次做思路是先试图分析倒牛奶过程的数学原理,找到合适的公式。 -其实完全不需要,一次不过六种倒的方案,只需要递归遍历就好了。 -递归判结束的标志是,倒完后的ABC情况前面出现过了。用一个bool数组liter[A][B][C]记录是否已经出现对应情况。程序答案/* ID: penglin3 PROG: milk3 LANG: C++11 */ #include <iostream>原创 2016-07-06 16:48:26 · 266 阅读 · 0 评论 -
section 1.5 numtri
-首先想到的这个方法太笨了 -还是需要递归算法/* ID: penglin3 PROG: numtri LANG: C++11 */ #include <iostream> #include <fstream> #include <vector> #include <math.h> using namespace std;//fstream 需要std合法范围#define max(a,b) (a原创 2016-07-06 19:51:50 · 242 阅读 · 0 评论 -
section 1.5 pprime
-先生成回文数 -生成回文数的迭代函数比较复杂,因为是新手,这里处理应该没那么好 -质数判定,先列出sqrt(b)以内的质数表(100,000,000最多只需要列10,000以内),用待测数N依次除以这些质数,求余 -生成质数表的函数很通用 -没有必要用Miller-Rabin算法/* ID: penglin3 PROG: pprime LANG: C++11 */ #include <io原创 2016-07-08 18:42:31 · 266 阅读 · 0 评论 -
section 1.5 sprime
-这道题和section 1.5 pprime思路几乎一模一样 -质数验证函数分了两类,num<=10000和num>=10000"YOUR PROGRAM ('sprime') WORKED FIRST TIME! That's fantastic and a rare thing. Please accept these special automated congratulations.原创 2016-07-08 20:05:09 · 311 阅读 · 0 评论