Browse Source

Initial commit

master
Abheek Dhawan 3 years ago
commit
8ccf561c67
  1. BIN
      codeforces/Caps Lock/a.out
  2. 40
      codeforces/Caps Lock/index.cpp
  3. BIN
      codeforces/Next Round/a.out
  4. 30
      codeforces/Next Round/index.cpp
  5. BIN
      codeforces/Soldier and Bananas/a.out
  6. 18
      codeforces/Soldier and Bananas/index.cpp
  7. BIN
      codeforces/Team/a.out
  8. 21
      codeforces/Team/index.cpp
  9. BIN
      codeforces/Watermelon/a.out
  10. 15
      codeforces/Watermelon/index.cpp
  11. BIN
      codeforces/Way Too Long Words/a.out
  12. 21
      codeforces/Way Too Long Words/index.cpp
  13. BIN
      usaco/Teleportation/a.out
  14. 21
      usaco/Teleportation/index.cpp

BIN
codeforces/Caps Lock/a.out

Binary file not shown.

40
codeforces/Caps Lock/index.cpp

@ -0,0 +1,40 @@
using namespace std;
#include <iostream>
#include <string>
string parseString(string n) {
string m = n;
string o = n;
for (int i = 0; i < n.length(); i++) {
m[i] = toupper(n[i]);
}
o = m;
o[0] = tolower(m[0]);
if (m == n) {
return "v1";
} else if (o == n) {
return "v2";
} else {
return "v3";
}
}
int main() {
string n;
cin >> n;
string w;
w = parseString(n);
if (w == "v3") {
cout << n << endl;
} else {
for (int i = 0; i < n.length(); i++) {
if (i == 0 && w == "v2") {
n[0] = toupper(n[0]);
} else {
n[i] = tolower(n[i]);
}
}
cout << n << endl;
}
}

BIN
codeforces/Next Round/a.out

Binary file not shown.

30
codeforces/Next Round/index.cpp

@ -0,0 +1,30 @@
using namespace std;
#include <iostream>
int main() {
int n, k;
cin >> n >> k;
int w;
int a = 0;
for (int i = 0; i < n; i++) {
int j;
cin >> j;
if (j == 0) {
break;
}
if (i == k - 1) {
w = j;
a++;
} else if (i > k - 1) {
if (j == w) {
a++;
} else {
break;
}
} else {
a++;
}
}
cout << a << endl;
}

BIN
codeforces/Soldier and Bananas/a.out

Binary file not shown.

18
codeforces/Soldier and Bananas/index.cpp

@ -0,0 +1,18 @@
using namespace std;
#include <iostream>
int main() {
int k, n, total_cost;
total_cost = 0;
long w;
cin >> k >> n >> w;
for (int i = 1; i < w + 1; i++) {
total_cost += i * k;
}
total_cost -= n;
if (total_cost < 0) {
total_cost = 0;
}
cout << total_cost << endl;
}

BIN
codeforces/Team/a.out

Binary file not shown.

21
codeforces/Team/index.cpp

@ -0,0 +1,21 @@
using namespace std;
#include <iostream>
int main() {
int n;
int c = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int k = 0;
for (int j = 0; j < 3; j++) {
int l;
cin >> l;
k += l;
}
if (k >= 2) {
c += 1;
}
}
cout << c << endl;
}

BIN
codeforces/Watermelon/a.out

Binary file not shown.

15
codeforces/Watermelon/index.cpp

@ -0,0 +1,15 @@
using namespace std;
#include <iostream>
int main() {
int n;
int i;
cin >> n;
i = n - 2;
if (i % 2 == 0 && i > 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}

BIN
codeforces/Way Too Long Words/a.out

Binary file not shown.

21
codeforces/Way Too Long Words/index.cpp

@ -0,0 +1,21 @@
using namespace std;
#include <iostream>
#include <string.h>
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
int length = s.length();
char first = s.front();
char last = s.back();
if (length > 10) {
cout << first << length << last << endl;
} else {
cout << s << endl;
}
}
}

BIN
usaco/Teleportation/a.out

Binary file not shown.

21
usaco/Teleportation/index.cpp

@ -0,0 +1,21 @@
#include <iostream>
int a, b, x, y;
int main() {
std::cin >> a >> b >> x >> y;
int path1;
int path2;
int path3;
int ans;
path1 = std::abs(a - b);
path2 = std::abs(a - x) + std::abs(y - b);
path3 = std::abs(a - y) + std::abs(x - b);
ans = path1;
if (path2 < ans) {
ans = path2;
}
if (path3 < ans) {
ans = path3;
}
std::cout << ans << std::endl;
}
Loading…
Cancel
Save