Project Euler

16問目

未確認。あんさいんどろんぐろんぐなので後でとく。 #include<iostream> using namespace std; int main(){ unsigned long long int p=1; unsigned long long int n=0; for(int i=0;i<1000;i++) { p*=2; } cout<<p<<endl; while(p>0) { n+= p%10; p/=10; cout<</p<<endl;></iostream>

14問目

#include<iostream> using namespace std; int main(){ unsigned long int max=0; unsigned long int maxans=0; unsigned long int p=0; unsigned long int count=0; for(unsigned long int i=999999;i>=0;i--) { count=0; p=i; while(p!=1) { if(p%2==0) { p=p/2; cou</iostream>…

13問目

#include<iostream> using namespace std; int main(){ int num[100][50]; int buf[50]; int mod[50]; int ans[50]; char c; for(int i=0;i<100;i++) { for(int p=0;p<50;p++) { cin>>c; num[i][p]=c-'0'; buf[p]=0; mod[p]=0; ans[p]=0; } } for(int i=0;i<50;i++) { </iostream>…

12問目

#include <iostream> #include <math.h> using namespace std; int main(){ int sq=0; int count=0; int prv=0; for(long long int i=1;i<100000000000000000;i++) { sq+=i; if( sqrt((double)sq) - floor(sqrt((double)sq))==0.0) count--; for(int n=1; n<=sq; n++ ) { if(sq</math.h></iostream>…

11問目

斜めって2方向あるんですよ奥さん。 In the 2020 grid below, four numbers along a diagonal line have been marked in red.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81…

第10問

The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million. #include <iostream> #include <math.h> using namespace std; long long int prime[1000000]; long long int table[100000000]; int primeCall(){ int flag=0; prim</math.h></iostream>…

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>…

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>…