
C++
文章平均质量分 78
要个男盆友扭蛋
这个作者很懒,什么都没留下…
展开
-
Project Euler:Problem 49 Prime permutations
The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are perm原创 2015-06-07 11:12:06 · 692 阅读 · 0 评论 -
Project Euler :Problem 54 Poker hands
In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:High Card: Highest value card.One Pair: Two cards of the same value.Two Pairs: Tw原创 2015-07-07 14:50:27 · 1202 阅读 · 1 评论 -
Project Euler:Problem 60 Prime pair sets
The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 a原创 2015-07-13 20:05:35 · 924 阅读 · 0 评论 -
Project Euler:Problem 61 Cyclical figurate numbers
Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:Triangle P3,n=n(n+1)/2 1, 3,原创 2015-07-14 15:13:42 · 861 阅读 · 0 评论 -
Project Euler:Problem 62 Cubic permutations
The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits原创 2015-07-14 15:18:33 · 657 阅读 · 0 评论 -
Project Euler:Problem 56 Powerful digit sum
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each num原创 2015-07-07 22:25:47 · 756 阅读 · 1 评论 -
Project Euler:Problem 57 Square root convergents
It is possible to show that the square root of two can be expressed as an infinite continued fraction.√ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213...By expanding this for the first four ite原创 2015-07-07 22:53:39 · 683 阅读 · 0 评论 -
Project Euler:Problem 55 Lychrel numbers
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.Not all numbers produce palindromes so quickly. For example,349 + 943 = 1292,1292 + 2921 = 42134213 + 3124 = 7337That is原创 2015-07-07 15:40:16 · 876 阅读 · 0 评论 -
Project Euler:Problem 64 Odd period square roots
All square roots are periodic when written as continued fractions and can be written in the form:√N = a0 +1 a1 +1 a2 +1 a3 + ...F原创 2015-07-14 22:35:46 · 691 阅读 · 0 评论 -
Project Euler:Problem 63 Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.How many n-digit positive integers exist which are also an nth power?这样的数字满原创 2015-07-14 17:04:48 · 1197 阅读 · 0 评论 -
Project Euler:Problem 53 Combinatoric selections
There are exactly ten ways of selecting three from five, 12345:123, 124, 125, 134, 135, 145, 234, 235, 245, and 345In combinatorics, we use the notation, 5C3 = 10.In general,nCr =原创 2015-07-01 22:08:09 · 594 阅读 · 0 评论 -
Project Euler:Problem 52 Permuted multiples
It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, con原创 2015-07-01 20:23:50 · 643 阅读 · 0 评论 -
Project Euler:Problem 47 Distinct primes factors
The first two consecutive numbers to have two distinct prime factors are:14 = 2 × 715 = 3 × 5The first three consecutive numbers to have three distinct prime factors are:644 = 2² × 7 × 23原创 2015-06-07 10:31:00 · 719 阅读 · 0 评论 -
hihocoder #1111 : Huffman编码
时间限制:30000ms单点时限:3000ms内存限制:256MB描述给定一个大小为n的字符集Σ中每个字符出现的频数,求不同的Huffman编码的数量模109 + 7。一个编码是一个从Σ到01字符串的函数。 一个Huffman编码是一个由以下过程生成的编码:初始时每个字符为一个集合。初始时所有字符对应到空字符串。一个集合S的频数w(S)定义为S内所有原创 2015-05-18 21:59:13 · 1124 阅读 · 0 评论 -
Project Euler:Problem 58 Spiral primes
Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed.37 36 35 34 33 32 3138 17 16 15 14 13 3039 18 5 4 3 12 2940 19 6 1 2 11原创 2015-07-08 20:48:55 · 747 阅读 · 0 评论 -
Project Euler:Problem 51 Prime digit replacements
By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.By replacing the 3rd and 4th digits of 56**3 with th原创 2015-07-01 19:58:32 · 803 阅读 · 0 评论 -
hihocoder:博弈游戏·Nim游戏·二
时间限制:10000ms单点时限:1000ms内存限制:256MB描述Alice和Bob这一次准备玩一个关于硬币的游戏:N枚硬币排成一列,有的正面朝上,有的背面朝上,从左到右依次编号为1..N。现在两人轮流翻硬币,每次只能将一枚正面朝上的硬币翻过来,并且可以随自己的意愿,在一枚硬币翻转后决定要不要将该硬币左边的任意一枚硬币也翻一次(正面翻到背面或背面翻到原创 2015-05-16 21:29:45 · 579 阅读 · 0 评论 -
Project Euler:Problem 59 XOR decryption
Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and原创 2015-07-08 22:33:16 · 1077 阅读 · 0 评论 -
hihocoder:随机斐波那契
妈妈说题目要从简单的做起!描述大家对斐波那契数列想必都很熟悉:a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1)。现在考虑如下生成的斐波那契数列:a0 = 1, ai = aj + ak, i > 0, j, k从[0, i-1]的整数中随机选出(j和k独立)。现在给定n,要求求出E(an),即各种可原创 2015-05-03 21:02:07 · 870 阅读 · 1 评论 -
hihocoder #1052 : 基因工程
时间限制:1000ms单点时限:1000ms内存限制:256MB描述小Hi和小Ho正在进行一项基因工程实验。他们要修改一段长度为N的DNA序列,使得这段DNA上最前面的K个碱基组成的序列与最后面的K个碱基组成的序列完全一致。 例如对于序列"ATCGATAC"和K=2,可以通过将第二个碱基修改为"C"使得最前面2个碱基与最后面两个碱基都为"AC"。当然还原创 2015-05-21 13:36:53 · 1193 阅读 · 0 评论 -
hihocoder #1099 : Constellations
时间限制:10000ms单点时限:1000ms内存限制:256MB描述Recently Little Hi started to like astronomy and downloaded the pictures of K constellations. He wonders how many of them he can spot in the nigh原创 2015-05-19 21:56:46 · 828 阅读 · 0 评论 -
Project Euler:Problem 67 Maximum path sum II
By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.37 42 4 68 5 9 3That is, 3 + 7 + 4 + 9 = 23.Find th原创 2015-07-15 23:01:02 · 654 阅读 · 0 评论 -
Project Euler:Problem 71 Ordered fractions
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called a reduced proper fraction.If we list the set of reduced proper fractions for d ≤ 8 in ascending or原创 2015-07-17 13:14:05 · 647 阅读 · 0 评论 -
Project Euler:Problem 65 Convergents of e
The square root of 2 can be written as an infinite continued fraction.√2 = 1 +1 2 +1 2 +1 2 +1 2 + ...The原创 2015-07-15 14:57:34 · 880 阅读 · 0 评论 -
Project Euler:Problem 86 Cuboid route
A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F, sits in the opposite corner. By travelling on the surfaces of the room the shortest "straight line" distance fr原创 2015-07-22 17:04:37 · 944 阅读 · 0 评论 -
Project Euler:Problem 87 Prime power triples
The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way:28原创 2015-07-23 20:59:37 · 801 阅读 · 0 评论 -
vs2013下如何调试main带参数的程序
vs2013下如何调试main带参数的程序原创 2015-11-13 22:10:47 · 5723 阅读 · 0 评论 -
最长回文子串
方法一:分治回文有两种类型:奇数长度的回文和偶数长度的回文字符串表示为s,s的最长回文子串用ans表示。奇数长度回文:以i为对称中心,对称半径为j(j>=0)(i-j) ... i ... (i+j) 总长度是2j-1在i-j和i+j在合理范围内时,如果有s[i-j]==s[i+j],而且ans的长度小于2j-1,则令ans=s.substr(i-j,2j-1),然后j++,继续比较s[i原创 2016-01-08 19:44:41 · 466 阅读 · 0 评论 -
回文字符串切割问题
问题描述对任意一个字符串进行切割,使得切割后的每一个字符串都是回文字符串。列出切割后的所有结果。方法一:深度优先搜索以string s的下标调用dfs函数,index表示当前要开始切割的下标,i表示目前要切割的终点位置,其中index<=i//判断是否是回文bool isPalindrome(string &s){ for(int i=0;i<s.length()/2;i++)原创 2016-01-08 19:46:04 · 1141 阅读 · 0 评论 -
C++编程练习
字符的左右移动题目字符串是任意的*和字母的组合,设计算法,把*都移到最左边,字母都移到最右边且保持相对顺序不变。实现逆序处理字符串。双指针,一个指针alpha最初指向最右边的字符,另一个last指针最初指向最右边的*。当alpha指向字母时,就和last指向的字符互换,并且这两个指针同时向左移一位。当alpha指向*时,只有alpha向左移动一位。当alpha<0时,结束。代码void原创 2016-01-08 21:42:11 · 999 阅读 · 0 评论 -
求职之C++牛客网刷题总结
把平时在印象笔记上记录的内容分享一下。。。1.必须使用初始化列表的情况: 1>常量成员const:常量成员只能初始化不能赋值 2>引用类型:必须在定义时初始化,并且不能重新赋值 3>没有默认构造函数的类类型:因为使用初始化列表可以不必调用默认构造函数来初始化,而是直接调用拷贝构造函数初始化。2.小端模式高地址存放高位,低地址存放低原创 2016-10-01 16:10:10 · 2421 阅读 · 0 评论 -
求职之C++小知识点整理
1.顺序容器1.顺序容器:vector,deque,list,forward_list,array,string。其中除list和forward_list外,其它都支持快速随机访问。 dequeint>a={1,2,3,4,5,6}; couta[4]endl;2.通常使用vector原创 2016-10-05 15:24:53 · 1161 阅读 · 0 评论 -
Project Euler:Problem 85 Counting rectangles
By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles:Although there exists no rectangular grid that contains exactly two million rectangles,原创 2015-07-22 15:02:29 · 778 阅读 · 0 评论 -
Project Euler:Problem 80 Square root digital expansion
It is well known that if the square root of a natural number is not an integer, then it is irrational. The decimal expansion of such square roots is infinite without any repeating pattern at all.T原创 2015-07-20 14:35:00 · 539 阅读 · 0 评论 -
Project Euler:Problem 69 Totient maximum
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are原创 2015-07-16 22:12:56 · 616 阅读 · 1 评论 -
Project Euler:Problem 68 Magic 5-gon ring
Consider the following "magic" 3-gon ring, filled with the numbers 1 to 6, and each line adding to nine.Working clockwise, and starting from the group of three with the numerically lowest exte原创 2015-07-16 21:28:01 · 1092 阅读 · 0 评论 -
Project Euler:Problem 70 Totient permutation
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n which are relatively prime to n. For example, as 1, 2,原创 2015-07-17 12:59:40 · 783 阅读 · 0 评论 -
Project Euler:Problem 76 Counting summations
It is possible to write five as a sum in exactly six different ways:4 + 13 + 23 + 1 + 12 + 2 + 12 + 1 + 1 + 11 + 1 + 1 + 1 + 1How many different ways can one hundred be written as a su原创 2015-07-18 16:46:12 · 939 阅读 · 0 评论 -
Project Euler:Problem 72 Counting fractions
Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called a reduced proper fraction.If we list the set of reduced proper fractions for d ≤ 8 in ascending or原创 2015-07-17 14:01:38 · 1004 阅读 · 0 评论 -
Project Euler:Problem 74 Digit factorial chains
The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145:1! + 4! + 5! = 1 + 24 + 120 = 145Perhaps less well known is 169, in that it produces the原创 2015-07-17 19:21:49 · 827 阅读 · 0 评论