2010-01-01から1ヶ月間の記事一覧

8問目。

Find the greatest product of five consecutive digits in the 1000-digit number.73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698…

7問目。

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10001st prime number? #include <iostream> using namespace std; long long int primeCall(unsigned int NM){ long long int prime[50000]; long</iostream>…

6問目。

The sum of the squares of the first ten natural numbers is,1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)^2 = 552 = 3025 Hence the difference between the sum of the squares of the …

5問目。

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest number that is evenly divisible by all of the numbers from 1 to 20? #include <iostream> using namespace std; int main() { </iostream>…

4問目。

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91*99.Find the largest palindrome made from the product of two 3-digit numbers. #include <iostream> using namespace std; int</iostream>…

第2問

#include <iostream> #include <time.h> using namespace std; int main() { unsigned long long int l=0; unsigned long long int r=1; unsigned long long int m=0; unsigned long int ans =0; for(long long int i=0;i<=4000000;i++){ if(m>4000000)break; m=l+r; //cout<</time.h></iostream>

3問目。

効率が悪いし、最悪の場合の処理時間がΟ(n^2)。 効率のよい実装をもちょっと考えれるようになりたいです。 #include <iostream> #include <time.h> using namespace std; unsigned int primeCall(unsigned NM){ unsigned int prime[50000]; unsigned int box[100000]; unsigned</time.h></iostream>…

breakにつまづく。

深夜にソースを書いちゃダメーっ! 3問目を解こうと、エラトステネスのふるいを実装しようと試みてちょっと挫折気味。 #include <iostream> #include <time.h> using namespace std; int erasto(int NM){ int n[50]; int box[100000]; int ans=0; int p=0; for(p=0;p<50;p++)n[</time.h></iostream>…

2問目。足りない。。

未だできてないけど。 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...Find the sum of all the even-valued term…

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000. #include <iostream> #include <time.h> using namespace std; int main() { </time.h></iostream>…