-
Notifications
You must be signed in to change notification settings - Fork 0
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
62 changed files
with
4,169 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,29 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
|
||
#include <cstdlib> | ||
#include <cstdio> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
string s; | ||
cin >> s; | ||
int num = 0; | ||
for(int i = 0; i < s.size(); ++i) { | ||
num += s[i] - '0'; | ||
} | ||
const char *numbers[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; | ||
|
||
stringstream ss; | ||
ss << num; | ||
ss >> s; | ||
for(int i = 0; i < s.size()-1; ++i) { | ||
cout << numbers[s[i] - '0'] << " "; | ||
} | ||
cout << numbers[s[s.size()-1] - '0'] << 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <vector> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
class checkRecord | ||
{ | ||
public: | ||
string id; | ||
string checkIn; | ||
string checkOut; | ||
/* data */ | ||
}; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int n; | ||
cin >> n; | ||
vector<checkRecord> v; | ||
for(int i = 0; i < n; ++i) { | ||
checkRecord tmp; | ||
cin >> tmp.id >> tmp.checkIn >> tmp.checkOut; | ||
v.push_back(tmp); | ||
} | ||
string earlyId, lateId; | ||
string earlyTime = "99:99:99", lateTime = "00:00:00"; | ||
for(int i = 0; i < v.size(); ++i) { | ||
if(v[i].checkIn <= earlyTime) { | ||
earlyId = v[i].id; | ||
earlyTime = v[i].checkIn; | ||
} | ||
} | ||
for(int i = 0; i < v.size(); ++i) { | ||
if(v[i].checkOut >= lateTime) { | ||
lateId = v[i].id; | ||
lateTime = v[i].checkOut; | ||
} | ||
} | ||
cout << earlyId << " " << lateId << 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
using namespace std; | ||
|
||
struct record | ||
{ | ||
int sum; | ||
int startIndex; | ||
int endIndex; | ||
/* data */ | ||
}; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int n; | ||
scanf("%d", &n); | ||
vector<int> v(n, 0); | ||
for(int i = 0; i < n; ++i) { | ||
scanf("%d", &v[i]); | ||
} | ||
record maxSum; | ||
maxSum.sum = -1; | ||
record tmp; | ||
tmp.sum = -1; | ||
tmp.startIndex = 0; | ||
for(int i = 0; i < n; ++i) { | ||
if(-1 == tmp.sum && v[i] < 0) { | ||
tmp.startIndex = i + 1; | ||
continue; | ||
} | ||
else if(-1 == tmp.sum && v[i] >= 0) { | ||
tmp.sum = 0; | ||
tmp.startIndex = i; | ||
} | ||
tmp.endIndex = i; | ||
tmp.sum += v[i]; | ||
if(tmp.sum > maxSum.sum) { | ||
maxSum.sum = tmp.sum; | ||
maxSum.startIndex = tmp.startIndex; | ||
maxSum.endIndex = tmp.endIndex; | ||
} | ||
else if(tmp.sum < 0) { | ||
tmp.sum = -1; | ||
tmp.startIndex = i+1; | ||
} | ||
} | ||
if(maxSum.sum < 0) | ||
printf("0 %d %d\n", v[0], v[n-1]); | ||
else | ||
printf("%d %d %d\n", maxSum.sum, v[maxSum.startIndex], v[maxSum.endIndex]); | ||
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,27 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
int n; | ||
scanf("%d", &n); | ||
int now = 0, result = 0, next; | ||
for(int i = 0; i < n; ++i) { | ||
scanf("%d", &next); | ||
if(now >= next) { | ||
result += (now - next) * 4 + 5; | ||
} | ||
else { | ||
result += (next - now) * 6 + 5; | ||
} | ||
now = next; | ||
} | ||
printf("%d\n", result); | ||
|
||
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,52 @@ | ||
#include <iostream> | ||
#include <vector> | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
using namespace std; | ||
|
||
const int MAXNUM = 1001; | ||
const int MAXPLUS = 2001; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
vector<double> v1(MAXNUM, 0); | ||
vector<double> v2(MAXNUM, 0); | ||
vector<double> result(MAXPLUS, 0); | ||
int n, nk; | ||
double ak; | ||
scanf("%d", &n); | ||
for(int i = 0; i < n; ++i) { | ||
scanf("%d%lf", &nk, &ak); | ||
v1[nk] = ak; | ||
} | ||
scanf("%d", &n); | ||
for(int i = 0; i < n; ++i) { | ||
scanf("%d%lf", &nk, &ak); | ||
v2[nk] = ak; | ||
} | ||
|
||
for(int i = 0; i < MAXNUM; ++i) { | ||
for(int j = 0; j < MAXNUM; ++j) { | ||
if(0 == v1[i] || 0 == v2[j]) | ||
continue; | ||
result[i+j] += v1[i] * v2[j]; | ||
} | ||
} | ||
int total = 0; | ||
for(int i = 0; i < MAXPLUS; ++i) { | ||
if(0 != result[i]) { | ||
++total; | ||
} | ||
} | ||
printf("%d", total); | ||
for(int i = MAXPLUS-1; i >= 0; --i) { | ||
if(0 != result[i]) { | ||
printf(" %d %.1f", i, result[i]); | ||
} | ||
} | ||
printf("\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,69 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
typedef long long lint; | ||
|
||
int trans(char c) { | ||
if(c >= '0' && c <= '9') | ||
return c - '0'; | ||
else if(c >= 'a' && c <= 'z') | ||
return c - 'a' + 10; | ||
return 0; | ||
} | ||
|
||
lint s2int(string s, int radix) { | ||
lint result = 0; | ||
for(int i = 0; i < s.size(); ++i) { | ||
result = result * radix + trans(s[i]); | ||
if(result < 0) { | ||
return -1; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
string s1; | ||
string s2; | ||
int tag, radix; | ||
cin >> s1 >> s2 >> tag >> radix; | ||
if(2 == tag) | ||
swap(s1, s2); | ||
lint a = 0; | ||
for(int i = 0; i < s1.size(); ++i) { | ||
a = a * radix + trans(s1[i]); | ||
} | ||
int minRadix = -1; | ||
for(int i = 0; i < s2.size(); ++i) { | ||
minRadix = max( minRadix, trans(s2[i]) ); | ||
} | ||
++minRadix; | ||
lint cur = 0, pre = -1; | ||
|
||
lint low = max(minRadix, 2), high = a + 1, mid; | ||
|
||
lint result = -1; | ||
while(low <= high) { | ||
mid = (low + high) / 2; | ||
cur = s2int(s2, mid); | ||
if( cur >= a || -1 == cur ){ | ||
if( cur == a && (mid < result || -1 == result) ) | ||
result = mid; | ||
high = mid - 1; | ||
} | ||
else { | ||
low = mid + 1; | ||
} | ||
} | ||
if(result != -1){ | ||
cout << result << endl; | ||
} | ||
else | ||
cout << "Impossible" << 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
double bet[3][3]; | ||
const char out[3] = {'W', 'T', 'L'}; | ||
for(int i = 0; i < 3; ++i) | ||
scanf("%lf%lf%lf", &bet[i][0], &bet[i][1], &bet[i][2]); | ||
double a[3]; | ||
double result = 1.0; | ||
for(int i = 0; i < 3; ++i) { | ||
a[i] = max( bet[i][0], max(bet[i][1], bet[i][2]) ); | ||
result *= a[i]; | ||
for(int j = 0; j < 3; ++j) { | ||
if(a[i] == bet[i][j]) { | ||
printf("%c ", out[j]); | ||
break; | ||
} | ||
} | ||
} | ||
result = (a[0] * a[1] * a[2] * 0.65 - 1.0) * 2.0 ; | ||
printf("%.2f\n", result); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.