Last active
June 20, 2017 11:56
-
-
Save dicenull/637bfaa7f0087e13a978772e404c29fa to your computer and use it in GitHub Desktop.
pck2016
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> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
int E, Y; | |
int magic[] = { 1868, 1912, 1926, 1989, 2017 }; | |
string magic_c[] = { "M", "T", "S", "H" }; | |
cin >> E >> Y; | |
switch (E) | |
{ | |
case 0: | |
for (int i = 0; i < 4; i++) | |
{ | |
if (magic[i] <= Y && Y < magic[i + 1]) | |
cout << magic_c[i] << Y - magic[i] + 1; | |
} | |
break; | |
case 1: | |
case 2: | |
case 3: | |
case 4: | |
cout << Y + magic[E - 1] - 1; | |
break; | |
} | |
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 main() | |
{ | |
int W, H, C; | |
int ans = 1; | |
cin >> W >> H >> C; | |
if (W > H) | |
{ | |
int tmp = W; | |
W = H; | |
H = tmp; | |
} | |
for (int i = W; i >= 1; i--) | |
{ | |
if (H % i == 0) | |
{ | |
ans = (H / i) * (W / i); | |
break; | |
} | |
} | |
cout << ans * C << 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> | |
#include <vector> | |
#include <string> | |
#include <algorithm> | |
using namespace std; | |
void swap(int &a, int &b) | |
{ | |
int tmp = a; | |
a = b; | |
b = tmp; | |
} | |
int main() | |
{ | |
int N; | |
int ans = 0; | |
cin >> N; | |
vector<string> table; | |
vector<int> p(3); | |
for (int i = 0; i < N; i++) | |
{ | |
cin >> p[0] >> p[1] >> p[2]; | |
sort(p.begin(), p.end()); | |
string s = to_string(p[0]) + " " + to_string(p[1]) + " " + to_string(p[2]); | |
bool contain = false; | |
for (int j = 0; j < table.size(); j++) | |
{ | |
if (table[j] == s) | |
{ | |
contain = true; | |
break; | |
} | |
} | |
if (contain) | |
ans++; | |
else | |
table.push_back(s); | |
} | |
cout << ans << 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> | |
#include <vector> | |
using namespace std; | |
int GetSum(vector<int> &p, int l, int r) | |
{ | |
int sum = 0; | |
for (int i = l; i < r; i++) | |
{ | |
if (p[i] >= 0) | |
{ | |
sum += p[i] * 2; | |
p[i + 1] -= p[i]; | |
} | |
} | |
return sum; | |
} | |
int main() | |
{ | |
int N; | |
int sum1, sum2; | |
cin >> N; | |
vector<int> p(N); | |
vector<int> tmp_p(N); | |
for (int i = 0; i < N; i++) | |
{ | |
cin >> p[i]; | |
tmp_p[i] = p[i]; | |
} | |
sum1 = GetSum(p, 0, N - 1); | |
if (p[N - 1] >= 0) | |
sum1 += p[N - 1]; | |
for(int i = 0;i < N;i++) | |
p[i] = tmp_p[i]; | |
sum2 = GetSum(p, 1, N - 1); | |
if (p[0] + p[N - 1] >= 0) | |
sum2 += p[0] + p[N - 1]; | |
cout << ((sum1 > sum2) ? sum2 : sum1) << 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> | |
#include <vector> | |
using namespace std; | |
// 配列のlからrまでのパンケーキを裏返す総和 | |
int GetSum(vector<int> &p, int l, int r) | |
{ | |
int sum = 0; | |
for (int i = l; i < r; i++) | |
{ | |
if (p[i] >= 0) | |
{ | |
// パンケーキ二枚分 | |
sum += p[i] * 2; | |
// 一緒に返した分 | |
p[i + 1] -= p[i]; | |
} | |
} | |
return sum; | |
} | |
int main() | |
{ | |
int N; | |
int sum1, sum2; | |
cin >> N; | |
vector<int> p(N); | |
vector<int> tmp_p(N); | |
// パンケーキ入力 | |
for (int i = 0; i < N; i++) | |
{ | |
cin >> p[i]; | |
tmp_p[i] = p[i]; | |
} | |
// 両端を考慮しない場合 | |
sum1 = GetSum(p, 0, N - 1); | |
if (p[N - 1] >= 0) | |
sum1 += p[N - 1]; | |
// 元に戻す | |
for(int i = 0;i < N;i++) | |
p[i] = tmp_p[i]; | |
// 両端を考慮する場合 | |
sum2 = GetSum(p, 1, N - 1); | |
// 両端の分を追加 | |
if (p[0] + p[N - 1] >= 0) | |
sum2 += p[0] + p[N - 1]; | |
// 小さいほうを出力 | |
cout << ((sum1 > sum2) ? sum2 : sum1) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment