Skip to content

Commit 00d86cd

Browse files
committed
Solve alot of problems :3
1 parent 2c296eb commit 00d86cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1974
-1
lines changed

AtCoder/055A - Restaurant.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int n;
7+
cin >> n;
8+
9+
cout << (n * 800) - (n / 15 * 200) << endl;
10+
11+
return 0;
12+
}

AtCoder/055B - Training Camp.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
long long n;
7+
cin >> n;
8+
9+
long long res = 1;
10+
for(int i = 1; i <= n; i++) {
11+
res *= i;
12+
res %= ((long long)1e9 + 7);
13+
}
14+
15+
cout << res << endl;
16+
17+
return 0;
18+
}

AtCoder/055C - Scc Puzzle.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
long long n, m;
6+
7+
long long can(long long mid) {
8+
long long S = mid, cc = mid * 2;
9+
10+
if(S <= n && cc <= m)
11+
return true;
12+
else {
13+
if(cc > m) return false;
14+
15+
long long needS = S - n;
16+
17+
if(cc <= (m - (needS * 2)))
18+
return true;
19+
else
20+
return false;
21+
}
22+
}
23+
24+
int main() {
25+
cin >> n >> m;
26+
27+
long long l = 0, r = 1e18, res;
28+
while(l <= r) {
29+
long long mid = (l + r) / 2;
30+
31+
if(can(mid)) {
32+
res = mid;
33+
l = mid + 1;
34+
} else
35+
r = mid - 1;
36+
}
37+
38+
cout << res << endl;
39+
40+
return 0;
41+
}

AtCoder/057A - Remaining Time.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int a, b;
7+
cin >> a >> b;
8+
9+
cout << (a + b) % 24 << endl;
10+
11+
return 0;
12+
}

AtCoder/057B - Checkpoints.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <cmath>
4+
5+
using namespace std;
6+
7+
vector<pair<long long, long long> > stu, pnt;
8+
9+
int main() {
10+
int n, m;
11+
cin >> n >> m;
12+
13+
int a, b;
14+
15+
while(n--) {
16+
cin >> a >> b;
17+
stu.push_back({a, b});
18+
}
19+
n = stu.size();
20+
21+
while(m--) {
22+
cin >> a >> b;
23+
pnt.push_back({a, b});
24+
}
25+
m = pnt.size();
26+
27+
long long res;
28+
int indx;
29+
30+
for(int i = 0; i < n; i++) {
31+
res = 1e18;
32+
33+
for(int j = 0; j < m; j++) {
34+
if(abs(stu[i].first - pnt[j].first) + abs(stu[i].second - pnt[j].second) < res) {
35+
res = abs(stu[i].first - pnt[j].first) + abs(stu[i].second - pnt[j].second);
36+
indx = j;
37+
}
38+
}
39+
40+
cout << indx + 1 << endl;
41+
}
42+
43+
return 0;
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <cmath>
4+
#include <algorithm>
5+
6+
using namespace std;
7+
8+
vector<long long> d;
9+
10+
int calc(long long i, long long j) {
11+
return (int)max(floor(log10(i)) + 1, floor(log10(j)) + 1);
12+
}
13+
14+
int main() {
15+
long long n, tmp;
16+
cin >> n;
17+
18+
tmp = sqrt(n);
19+
for(int i = 1; i <= tmp; i++)
20+
if(n % i == 0) {
21+
d.push_back(i);
22+
d.push_back(n / i);
23+
}
24+
25+
sort(d.begin(), d.end());
26+
27+
int res = 1e9;
28+
29+
for(int i = 0, j = d.size() - 1; i <= j; i++, j--)
30+
res = min(res, calc(d[i], d[j]));
31+
32+
cout << res << endl;
33+
34+
return 0;
35+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <cctype>
4+
5+
using namespace std;
6+
7+
int main() {
8+
string s;
9+
for(int i = 0; i < 3; i++) {
10+
cin >> s;
11+
cout << char(toupper(s[0]));
12+
}
13+
cout << endl;
14+
15+
return 0;
16+
}

AtCoder/059B - Comparison.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <cctype>
4+
5+
using namespace std;
6+
7+
int main() {
8+
string n1, n2;
9+
cin >> n1 >> n2;
10+
11+
if(n1.length() < n2.length()) {
12+
cout << "LESS" << endl;
13+
return 0;
14+
} else if(n1.length() > n2.length()) {
15+
cout << "GREATER" << endl;
16+
return 0;
17+
} else {
18+
for(int i = 0; i < n1.length(); i++)
19+
if((n1[i] - '0') > (n2[i] - '0')) {
20+
cout << "GREATER" << endl;
21+
return 0;
22+
} else if((n1[i] - '0') < (n2[i] - '0')) {
23+
cout << "LESS" << endl;
24+
return 0;
25+
}
26+
}
27+
28+
cout << "EQUAL" << endl;
29+
30+
return 0;
31+
}

AtCoder/060A - Shiritori.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <string>
3+
4+
using namespace std;
5+
6+
int main() {
7+
string s1, s2, s3;
8+
cin >> s1 >> s2 >> s3;
9+
10+
if(s1[s1.length() - 1] == s2[0] && s2[s2.length() - 1] == s3[0])
11+
cout << "YES" << endl;
12+
else
13+
cout << "NO" << endl;
14+
15+
return 0;
16+
}

AtCoder/060B - Choose Integers.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int a, b, c;
7+
cin >> a >> b >> c;
8+
9+
int tmp;
10+
for(int i = 2; i < 10000; i++) {
11+
tmp = a * i;
12+
if((a + tmp) % b == c % b) {
13+
cout << "YES" << endl;
14+
return 0;
15+
}
16+
}
17+
18+
cout << "NO" << endl;
19+
20+
return 0;
21+
}

AtCoder/060C - Sentou.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <stdio.h>
2+
#include <vector>
3+
4+
using namespace std;
5+
6+
vector<long long> a;
7+
8+
int main() {
9+
long long n, t;
10+
scanf("%llu%llu", &n, &t);
11+
a.resize(n);
12+
for(int i = 0; i < n; ++i)
13+
scanf("%llu", &a[i]);
14+
15+
long long res = t;
16+
for(int i = 1; i < n; ++i) {
17+
if(a[i] - a[i-1] <= t)
18+
res += (a[i] - a[i-1]);
19+
else
20+
res += t;
21+
}
22+
23+
printf("%lld\n", res);
24+
25+
return 0;
26+
}

AtCoder/060D - Simple Knapsack.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <stdio.h>
2+
#include <vector>
3+
#include <algorithm>
4+
#include <memory.h>
5+
6+
using namespace std;
7+
8+
int const N = 101;
9+
long long n, w;
10+
long long dp[N][10000];
11+
vector<pair<long long, long long> > a;
12+
13+
long long calc(int index, long long sum) {
14+
if(index == n) return 0;
15+
if(dp[index][int(sum % 10000)] != -1) return dp[index][int(sum % 10000)];
16+
17+
long long res1 = 0, res2 = 0;
18+
if(sum >= a[index].first) res1 = calc(index + 1, sum - a[index].first) + a[index].second;
19+
res2 = calc(index + 1, sum);
20+
return dp[index][int(sum % 10000)] = max(res1, res2);
21+
}
22+
23+
int main() {
24+
scanf("%d%d", &n, &w);
25+
a.resize(n);
26+
for(int i = 0; i < n; ++i)
27+
scanf("%d%d", &a[i].first, &a[i].second);
28+
29+
memset(dp, -1, sizeof dp);
30+
printf("%lld\n", calc(0, w));
31+
32+
return 0;
33+
}

AtCoder/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Problems links
2+
3+
- [055A - Restaurant](http://abc055.contest.atcoder.jp/tasks/abc055_a)
4+
- [055B - Training Camp](http://abc055.contest.atcoder.jp/tasks/abc055_b)
5+
- [055C - Scc Puzzle](http://abc055.contest.atcoder.jp/tasks/arc069_a)
6+
- [057A - Remaining Time](http://abc057.contest.atcoder.jp/tasks/abc057_a)
7+
- [057B - Checkpoints](http://abc057.contest.atcoder.jp/tasks/abc057_b)
8+
- [057C - Digits in Multiplication](http://abc057.contest.atcoder.jp/tasks/abc057_c)
9+
- [059A - Three-letter acronym](http://abc059.contest.atcoder.jp/tasks/abc059_a)
10+
- [059B - Comparison](http://abc059.contest.atcoder.jp/tasks/abc059_b)
11+
- [060A - Shiritori](http://abc060.contest.atcoder.jp/tasks/abc060_a)
12+
- [060B - Choose Integers](http://abc060.contest.atcoder.jp/tasks/abc060_b)
13+
- [060C - Sentou](http://abc060.contest.atcoder.jp/tasks/arc073_a)
14+
- [060D - Simple Knapsack](http://abc060.contest.atcoder.jp/tasks/arc073_b)

CS Academy/24. Kth Special Number.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <iostream>
2+
#include <bitset>
3+
4+
using namespace std;
5+
6+
bitset<64> bs;
7+
8+
int main() {
9+
int k;
10+
cin >> k;
11+
12+
int n = 0, ones;
13+
14+
while(k) {
15+
n++;
16+
ones = 0;
17+
bs = n;
18+
19+
for(int i = bs.size() - 1; i >= 0; i--)
20+
if(bs[i] && bs[i+1]) {
21+
ones = 2;
22+
break;
23+
}
24+
25+
if(ones != 2) k--;
26+
}
27+
28+
cout << n << endl;
29+
30+
return 0;
31+
}
32+

CS Academy/24. Vector Size.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int n, size = 0, res = 0;;
7+
cin >> n;
8+
9+
int tmp;
10+
while(n--) {
11+
cin >> tmp;
12+
if(tmp) {
13+
size++;
14+
} else {
15+
if(size)
16+
size--;
17+
}
18+
19+
res = max(res, size);
20+
}
21+
22+
cout << res << endl;
23+
24+
return 0;
25+
}
26+

0 commit comments

Comments
 (0)