Skip to content

Commit 5ba515b

Browse files
authored
Kattis problems
1 parent 3b1236f commit 5ba515b

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

Kattis/Fridge/Fridge.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include<bits/stdc++.h>
2+
3+
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
4+
#define print(x) cout<<x<<"\n"
5+
#define For(x,y) for(int i = x; i < y; i++)
6+
typedef std::vector<int> vi;
7+
typedef std::vector<std::vector<int>> vvi;
8+
int n,x;
9+
10+
int memo[10001];
11+
12+
using namespace std;
13+
14+
int main()
15+
{
16+
ios_base::sync_with_stdio(false);
17+
string input;
18+
cin>>input;
19+
int ch[1000];
20+
for(int i = 0; i < input.size (); i++){
21+
ch[input.at(i) - '0']++;
22+
}
23+
int k = 0;
24+
int candidate = 0;
25+
for(int j = 1; j < 10; j++){
26+
ch[j]--;
27+
if(ch[j] < 0){
28+
candidate = j;
29+
break;
30+
}
31+
if(j == 9){
32+
k++;
33+
j = -1;
34+
}
35+
}
36+
int i = 0;
37+
if(candidate == 0){
38+
cout<<1;
39+
i++;
40+
}
41+
for(; i < k; i++){
42+
cout<<candidate;
43+
}
44+
cout<<candidate<<endl;
45+
}

Kattis/Seven Wonders/SevenWonders.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<bits/stdc++.h>
2+
3+
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
4+
#define print(x) cout<<x<<"\n"
5+
#define For(x,y) for(int i = x; i < y; i++)
6+
typedef std::vector<int> vi;
7+
typedef std::vector<std::vector<int>> vvi;
8+
int n,x;
9+
10+
int memo[10001];
11+
12+
using namespace std;
13+
14+
int main()
15+
{
16+
ios_base::sync_with_stdio(false);
17+
string input;
18+
cin>>input;
19+
int C = 0 , G = 0, T = 0;
20+
for(int i = 0; i < input.size (); i++){
21+
if(input.at (i) == 'C'){
22+
C++;
23+
}else if(input.at (i) == 'T'){
24+
T++;
25+
}else{
26+
G++;
27+
}
28+
}
29+
int ans = 0;
30+
if(C*G*T != 0){
31+
ans += min(C,min(G,T))*7;
32+
}
33+
ans += C*C + G*G + T*T;
34+
cout<<ans<<endl;
35+
}
36+

0 commit comments

Comments
 (0)