Created
May 1, 2016 14:02
-
-
Save oyakodon/29696ce967feed2d30c40dbfcdd6721c to your computer and use it in GitHub Desktop.
ABC001 / C++11
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 h1, h2; | |
cin >> h1; | |
cin >> h2; | |
cout << h1 - h2 << "\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
#include <iostream> | |
#include <iomanip> | |
using namespace std; | |
int main() { | |
double m; | |
cin >> m; | |
m = m / 1000; | |
int vv; | |
if (m < 0.1) | |
vv = 0; | |
else if (m <= 5) | |
vv = m * 10; | |
else if (6 <= m && m <= 30) | |
vv = m + 50; | |
else if (35 <= m && m <= 70) | |
vv = (m - 30) / 5 + 80; | |
else if (70 <= m) | |
vv = 89; | |
cout << setfill('0') << setw(2) << vv << "\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
#include <cstdio> | |
#include <math.h> | |
#include <vector> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <iomanip> | |
using namespace std; | |
int solveW(int Dis) { | |
double x = Dis / 60.0 + 0.05 + 1e-5; | |
x *= 10; | |
x = floor(x); | |
x = x / 10.0; | |
if (x <= 0.2) | |
return 0; | |
else if (x <= 1.5) | |
return 1; | |
else if (x <= 3.3) | |
return 2; | |
else if (x <= 5.4) | |
return 3; | |
else if (x <= 7.9) | |
return 4; | |
else if (x <= 10.7) | |
return 5; | |
else if (x <= 13.8) | |
return 6; | |
else if (x <= 17.1) | |
return 7; | |
else if (x <= 20.7) | |
return 8; | |
else if (x <= 24.4) | |
return 9; | |
else if (x <= 28.4) | |
return 10; | |
else if (x <= 32.6) | |
return 11; | |
else if (x >= 32.7) | |
return 12; | |
} | |
string solveDir(int Deg) { | |
if (Deg < 112.5) | |
return "N"; | |
else if (Deg < 337.5) | |
return "NNE"; | |
else if (Deg < 562.5) | |
return "NE"; | |
else if (Deg < 787.5) | |
return "ENE"; | |
else if (Deg < 1012.5) | |
return "E"; | |
else if (Deg < 1237.5) | |
return "ESE"; | |
else if (Deg < 1462.5) | |
return "SE"; | |
else if (Deg < 1687.5) | |
return "SSE"; | |
else if (Deg < 1912.5) | |
return "S"; | |
else if (Deg < 2137.5) | |
return "SSW"; | |
else if (Deg < 2362.5) | |
return "SW"; | |
else if (Deg < 2587.5) | |
return "WSW"; | |
else if (Deg < 2812.5) | |
return "W"; | |
else if (Deg < 3037.5) | |
return "WNW"; | |
else if (Deg < 3262.5) | |
return "NW"; | |
else if (Deg < 3487.5) | |
return "NNW"; | |
else | |
return "N"; | |
} | |
int main() { | |
int Deg, // 風向(角度を10倍) | |
Dis; // 風程(m) | |
cin >> Deg >> Dis; | |
string Dir = solveDir(Deg); | |
int W = solveW(Dis); | |
if (W == 0) { | |
cout << "C " << W << "\n"; | |
} | |
else { | |
cout << Dir << " " << W << "\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
#include <cstdio> | |
#include <math.h> | |
#include <vector> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <iomanip> | |
using namespace std; | |
string toHM(int v) | |
{ | |
double H = floor(v / 12.0); | |
double M = ((v * 5) - H * 60); | |
stringstream str; | |
str << setw(4) << setfill('0') << H * 100 + M; | |
return str.str(); | |
} | |
int main() { | |
int N = 0, s = 0, e = 0; | |
char c; // "-"読み飛ばし用 | |
cin >> N; | |
int arr[290] = { 0 }; | |
for (int i = 0; i < N; i++) { | |
cin >> s >> c >> e; | |
s = (s / 100) * 60 + (s % 100); | |
e = (e / 100) * 60 + (e % 100); | |
s = floor(s / 5.0); | |
e = floor((e - 1) / 5.0); | |
for (int j = s; j <= e; j++) { | |
arr[j + 1] = 1; | |
} | |
} | |
for (int i = 0; i < 289; i++) { | |
if (arr[i] == 0 && arr[i + 1] == 1) | |
{ | |
cout << toHM(i) << "-"; | |
} | |
if (arr[i] == 1 && arr[i + 1] == 0) | |
{ | |
cout << toHM(i) << "\n"; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment