-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 1000000 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int n_collatz(long long x) { | ||
int c = 1; | ||
|
||
while (x != 1) { | ||
if (x % 2) x = 3*x + 1; | ||
else x /= 2; | ||
|
||
c++; | ||
} | ||
|
||
return c; | ||
} | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
int max_n = 0; | ||
int max_i = -1; | ||
for (int i = 1; i <= MAX; i++) { | ||
int n = n_collatz(i); | ||
if (n > max_n) { | ||
max_n = n; | ||
max_i = i; | ||
} | ||
} | ||
|
||
cout << max_i << "\n"; | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
long long binomial(int x) { | ||
ll r = 1; | ||
|
||
for (int i = 2*x-1; i > x; i-=2) { | ||
r *= i; | ||
} | ||
for (int i = 2*x; i > x; i-=2) { | ||
r *= 2; | ||
} | ||
for (int i = 2; i <= x / 2; i++){ | ||
r /= i; | ||
} | ||
|
||
cout << r << endl; | ||
|
||
return r; | ||
} | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
for (int n = 1; n <= 20; n++) | ||
cout << binomial(n) << "\n"; | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 500 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
int n[MAX]; | ||
memset(n, 0, sizeof(int)*MAX); | ||
|
||
n[0] = 1; | ||
int p = 1000; | ||
int max_j = 1; | ||
|
||
for(int i = 1; i <= p; i++) { | ||
for (int j = 0; j < max_j; j++) { | ||
n[j] *= 2; | ||
} | ||
|
||
for (int j = 0; j < max_j; j++) { | ||
n[j+1] += n[j] / 10; | ||
n[j] %= 10; | ||
} | ||
if(n[max_j] > 0) max_j++; | ||
} | ||
|
||
int sum = 0; | ||
for(int i = 0; i < max_j; i++) { | ||
cout << n[i] << " "; | ||
sum += n[i]; | ||
} | ||
|
||
cout << sum << "\n"; | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
|
||
using namespace std; | ||
|
||
#define pb push_back | ||
#define eb emplace_back | ||
#define mk make_pair | ||
#define fi first | ||
#define se second | ||
|
||
#define MAX 50000 | ||
|
||
typedef long long ll; | ||
typedef pair<int, int> ii; | ||
const int INF = 0x3f3f3f3f; | ||
const double PI = acos(-1.0); | ||
|
||
int line(int n) { | ||
return ( n * (n - 1 ) ) / 2; | ||
} | ||
|
||
int main (void) { | ||
ios_base::sync_with_stdio(false); | ||
|
||
int t[MAX]; | ||
memset(t, 0, sizeof(int)*MAX); | ||
|
||
int j = 0; | ||
int l = 1; | ||
while (scanf("%d", t + line(l) + j) != EOF) { | ||
j++; | ||
|
||
if (j == l) { | ||
l++; | ||
j = 0; | ||
} | ||
} | ||
|
||
for (int i = l-2; i > 0; i--) { | ||
for (j = 0; j < i; j++) { | ||
t[line(i)+j] += max(t[line(i+1)+j],t[line(i+1)+j+1]); | ||
} | ||
} | ||
|
||
cout << t[0] << "\n"; | ||
|
||
return 0; | ||
} | ||
|