自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(40)
  • 收藏
  • 关注

原创 http://projecteuler.net/problem=40 [Answer:210]

#include using namespace std;int NthDigit( int n ){ int nNumberLength = 1; int nNumberCount = 9; int nNumberBegin = 1; while ( n > nNumberLength * nNumberCount ) {

2011-12-10 11:42:42 567

原创 http://projecteuler.net/problem=39 [Answer:840]

#include #include #include #include using namespace std;// a*a + b*b = c*c// then// a = (x*x - y*y)* k// b = (2*x*y) * k// if a is greater than b, than swap a and b// c = (x*x

2011-12-10 10:49:32 332

原创 http://projecteuler.net/problem=38 [Answer:932718654]

#include #include using namespace std;int main(){ int nMax = 0; for ( int number = 1; number < 10000; ++number ) { int digit[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

2011-12-10 09:09:34 341

原创 http://projecteuler.net/problem=37 [Answer:748317]

#include #include #include using namespace std;int main(){ const int N = 1000000; const int D = 1000; vector bPrime( N, true ); bPrime[0] = false; bPrime[1] = fa

2011-12-08 22:42:44 305

原创 http://projecteuler.net/problem=36 [Answer:872187]

#include using namespace std;bool IsPalindromic( int number, int base ){ int digit[32]; size_t count = 0; do { digit[count++] = number % base; number

2011-12-06 23:44:51 598

原创 http://projecteuler.net/problem=35 [Answer:55]

#include #include #include using namespace std;int main(){ const size_t N = 1000000; const size_t root = 1000; vector isprime(N); fill( isprime.begin(), isprime.end

2011-12-06 23:34:26 297

原创 http://projecteuler.net/problem=34 [Answer:40730]

#include using namespace std;int main(){ const int factorial[10] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880 }; int result = 0; for ( int n = 10; n < 362880 * 7; ++n ) {

2011-12-03 15:51:53 347

原创 http://projecteuler.net/problem=33 [Answer:100]

#include using namespace std;int GCD( int m, int n ){ int r = m % n; while ( r != 0 ) { m = n; n = r; r = m % n; } return n;}int main(){ int nu

2011-12-03 14:48:04 276

原创 http://projecteuler.net/problem=32 [Answer:45228]

#include #include #include using namespace std;bool IsPandigital( int a, int b, int c ){ if ( c = 10000 ) { return false; } bool bExist[10] = { true, false, false, false

2011-12-03 14:36:02 437

原创 http://projecteuler.net/problem=31 [Answer:73682]

#include #include #include using namespace std;int main(){ const int value[] = {1, 2, 5, 10, 20, 50, 100, 200 }; const int n = sizeof(value) / sizeof(value[0]); const int

2011-12-01 21:26:15 250

原创 http://projecteuler.net/problem=30 [Answer:443839]

#include using namespace std;int main(){ int powers[10]; for ( int i = 0; i < 10; ++i ) { powers[i] = i * i * i * i * i; } int sum = 0; for ( int n =

2011-12-01 00:33:20 289

原创 http://projecteuler.net/problem=29 [Answer:9183]

#include #include #include #include using namespace std;int main(){ const int N = 100; double dLogValue[N*N]; int count = 0; for ( int a = 2; a <= N; ++a )

2011-11-29 23:53:03 284

原创 http://projecteuler.net/problem=28 [Answer:669171001]

/*43 44 45 46 47 48 4942 21 22 23 24 25 2641 20 7 8 9 10 2740 19 6 1 2 11 2839 18 5 4 3 12 2938 17 16 15 14 13 3037 36 35 34 33 32 31right-up 1, 9, 25, 49 -> n*nleft-up

2011-11-29 23:37:47 359

原创 http://projecteuler.net/problem=27 [Answer:-59231]

#include #include using namespace std;bool IsPrime( int m ){ if ( m < 2 ) { return false; } int d = sqrt( m + 0.5 ); for ( int i = 2; i <= d; ++i ) {

2011-11-29 23:13:01 397

原创 http://projecteuler.net/problem=26 [Answer:983]

#include #include using namespace std;int main(){ const int N = 1000; int postion[N]; int d = 0; int longest = 0; for ( int i = 2; i < N; ++i ) { postion[1] = 0;

2011-11-27 22:50:53 310

原创 http://projecteuler.net/problem=25 [Answer:4782]

#include #include using namespace std;int main(){ // Fibonacci(n) = (((1+√5)/2)^n-((1-√5)/2)^n)/√5 ≈ ((1+√5)/2)^n/√5 // log(Fibonacci(n)) ≈ n*log((1+√5)/2)-log(√5) // 999*log(10) <

2011-11-27 21:54:33 408

原创 http://projecteuler.net/problem=24 [Answer:2783915460]

#include using namespace std;int main(){ const int N = 10; char x[N] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; const char stead = '*'; int factorial[N+1]; fact

2011-11-27 20:27:20 339

原创 http://projecteuler.net/problem=23 [Answer:4179871]

#include using namespace std;int main(){ const int N = 28124; bool bAbundant[N]; bAbundant[1] = false; for ( int nNum = 2; nNum < N; ++nNum ) { int nSum = 1

2011-11-27 10:43:55 289

原创 http://projecteuler.net/problem=22 [Answer:871198282]

#include #include #include #include using namespace std;int main(){ char ch; string strName; vector vecNameList; while ( cin >> ch ) { if ( ch >= 'A

2011-11-27 10:02:23 600

原创 http://projecteuler.net/problem=21 [Answer:31626]

#include using namespace std;int main(){ const int N = 10000; int nDivisorsDum[N]; fill( nDivisorsDum, nDivisorsDum+N, 0 ); for ( int i = 1; i < N; ++i ) {

2011-11-27 08:53:48 599

原创 http://projecteuler.net/problem=20 [Answer:648]

#include #include #include using namespace std;int main(){ vector numbers; numbers.push_back( 1 ); for ( int i = 2; i <= 100; ++i ) { for ( size_t k = 0; k

2011-11-27 08:41:48 248

原创 http://projecteuler.net/problem=19 [Answer:171]

#include using namespace std;int main(){ int nDaysInMonths[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int nYear = 1901; int nMonth = 1; int nDay = (1 +

2011-11-27 08:33:36 201

原创 http://projecteuler.net/problem=18 [Answer:1074]

#include #include using namespace std;int main(){    const int N = 15;    int x[N][N];    int sum[N][N];    cin >> x[0][0];    sum[0][0] = x[0][0];    for ( int i = 1; i     {

2011-11-27 00:46:34 247

原创 http://projecteuler.net/problem=17 [Answer:21124]

#include using namespace std;int main(){    int letters = 0;    for ( int n = 1; n     {        if ( n >= 1000 )        {            letters += sizeof("one thousand") - 2;        }

2011-11-27 00:44:44 483

原创 http://projecteuler.net/problem=16 [Answer:1366]

#include #include #include using namespace std;int main(){    vector numbers;    numbers.push_back( 1 );    for ( int i = 0; i     {        for ( size_t k = 0; k         {

2011-11-26 16:58:46 258

原创 http://projecteuler.net/problem=15 [Answer:137846528820]

#include using namespace std;int main(){    __int64 routes = 1;    int n = 40;    int m = 1;    while ( n > m )    {        routes *= n;        routes /= m;        --n;

2011-11-26 16:01:25 456

原创 http://projecteuler.net/problem=14 [Answer:837799]

#include using namespace std;int main(){    int longest_chain = 0;    int number = 0;    for ( int n = 1; n     {        __int64 tmp = n;        int terms = 1;        while ( tmp !

2011-11-26 15:46:35 253

原创 http://projecteuler.net/problem=13 [Answer:5537376230]

#include using namespace std;int main(){    double sum = 0.0;    double x;    while ( scanf("%lf", &x) != EOF )    {        sum += x;    }    printf("%.10e\n", sum);    return 0;

2011-11-25 23:30:41 757

原创 http://projecteuler.net/problem=12 [Answer:76576500]

// triangle(n) = n * (n + 1) / 2// factor((p1^a1)*(p2^a2)*(pm^am))=(a1+1)*(a2+1)*(am+1)#include #include using namespace std;void InitFactorCount( vector& count, int n ){ count.assign( n

2011-11-25 22:31:29 430

原创 http://projecteuler.net/problem=11 [Answer:70600674]

#include using namespace std;int main(){ const size_t N(20); int matrix[N][N]; for ( size_t i = 0; i  {  for ( size_t j = 0; j   {   cin >> matrix[i][j];  } } int greatest(0)

2011-11-23 23:31:14 484

原创 http://projecteuler.net/problem=10 [Answer:142913828922]

#include using namespace std;int main(){    const int N = 2000000;    const int d = 1414;        bool* bp = new bool[N];    fill( bp, bp+N, true );        __int64 sum = 2;

2011-11-22 23:48:51 257

原创 http://projecteuler.net/problem=9 [Answer:31875000]

// a*a + b*b = c*c// a = x*x - y*y // x > y// b = 2*x*y// c = x*x + y*y// 1000 = a+b+c = 2*x*(x+y)// x*(x+y)=500#include using namespace std;int main(){

2011-11-22 20:58:24 244

原创 http://projecteuler.net/problem=8 [Answer:40824]

#include #include using namespace std;int main(){string str, tmp;while ( cin >> tmp ){str.append( tmp );}int greatest(0);for ( string::siz

2011-11-22 20:57:53 238

原创 http://projecteuler.net/problem=7 [Answer:104743]

#include #include using namespace std;const size_t N = 10001;int main(){    vector prime(N);    vector square_of_prime(N);    prime[0] = 2;    square_of_prime[0] = 4;    si

2011-11-22 20:57:02 237

原创 http://projecteuler.net/problem=6 [Answer:25164150]

#include using namespace std;int sum_of_squares( int n ){    return n * (n + 1) * (n + n + 1) / 6;}int square_of_sum( int n ){    return n * (n + 1) / 2 * n * (n + 1) / 2;}

2011-11-22 20:56:28 267

原创 http://projecteuler.net/problem=5 [Answer:232792560]

#include using namespace std;int GCD( int m, int n ) // greatest common divisor{    if ( m     {        swap( m, n );    }    int r = m % n;    while ( r != 0 )    {        m

2011-11-22 20:55:51 382

原创 http://projecteuler.net/problem=4

#include #include using namespace std;int GeneratePalindromicNumber(int nFirstHalf){ int nResult = nFirstHalf; int nTemp = nFirstHalf; while (nTemp != 0) { nResult *=

2011-11-22 20:53:49 232

原创 http://projecteuler.net/problem=3

#include using namespace std;int main(){ __int64 nNumber = 600851475143LL; __int64 nResult = 0; for (__int64 i = 2; nNumber != 1; ++i) { while (nNumber % i == 0)

2011-11-22 20:52:48 270

原创 http://projecteuler.net/problem=2

#include using namespace std;int main(){ int a = 1; int b = 2; int c = a + b; int nSum = 0; while (b <= 4000000) { if (b % 2 == 0) { nSum += b

2011-11-22 20:51:59 238

原创 http://projecteuler.net/problem=1

#include using namespace std;int SumOfArithmeticSequence(int nEqualDiff, int nTopLimit){ int nCount = nTopLimit / nEqualDiff; int nSum = nEqualDiff * nCount * (nCount + 1) / 2; return

2011-11-22 20:50:02 306

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除