Created
September 5, 2017 06:20
-
-
Save dicenull/266efa9b0617a4f4cdbfaef684d3a238 to your computer and use it in GitHub Desktop.
pck2017 勉強会
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
// Atcoder Beginner Contest 006 B問題 | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
int N; | |
int num = 10007; | |
int ans = 0; | |
cin >> N; | |
vector<int> a(N + 3); | |
a[0] = 0; | |
a[1] = 0; | |
a[2] = 1; | |
for (int i = 3; i < N; i++) | |
{ | |
a[i] = ((a[i - 1] + a[i - 2] % num) + a[i - 3]) % num; | |
} | |
cout << a[N - 1] << endl; | |
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
// パソコン甲子園過去問 2014 4問目 | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
// init | |
int N, h, m; | |
int table[24 * 60] = { 0 }; | |
// input | |
cin >> N; | |
for (int i = 0; i < N; i++) | |
{ | |
cin >> h >> m; | |
table[h * 60 + m] = 1; | |
} | |
cin >> N; | |
for (int i = 0; i < N; i++) | |
{ | |
cin >> h >> m; | |
table[h * 60 + m] = 1; | |
} | |
// output | |
int count = 0; | |
for (int i = 0; i < 24 * 60; i++) | |
{ | |
if (table[i] != 0) | |
{ | |
if (count > 0) | |
cout << " "; | |
h = i / 60; | |
m = i % 60; | |
cout << h << ":"; | |
if (m < 10) | |
cout << "0"; | |
cout << m; | |
count++; | |
} | |
} | |
cout << endl; | |
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
// トリボナッチ数列を再起で実装 | |
#include <iostream> | |
using namespace std; | |
int trib(int n) | |
{ | |
if (n < 2) | |
{ | |
return 0; | |
} | |
if (n == 2) | |
{ | |
return 1; | |
} | |
return trib(n - 3) + trib(n - 2) + trib(n - 1); | |
} | |
int main() | |
{ | |
int N; | |
cin >> N; | |
cout << trib(N - 1) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment