Skip to content

Commit b829f98

Browse files
committed
Add 1316, 2908, 5622
1 parent 45c24a5 commit b829f98

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

BaekJoon/1316_그룹단어체커.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
#include <iostream>
3+
#include <bitset>
4+
using namespace std;
5+
6+
bool group(string str) {
7+
bitset<26> bits;
8+
char pin = str[0];
9+
bits.set(str[0]-97);
10+
for(int i=1; i<str.length(); i++) {
11+
int val = str[i] - 97;
12+
if(pin == str[i]) continue;
13+
if(pin != str[i] && bits.test(val)) return false;
14+
else if(pin != str[i] && !bits.test(val)) bits.set(val);
15+
pin = str[i];
16+
}
17+
return true;
18+
}
19+
20+
int main() {
21+
int n; cin>>n;
22+
string word;
23+
int cnt = 0;
24+
for(int i=0; i<n; ++i) {
25+
cin >> word;
26+
if(group(word)) cnt++;
27+
}
28+
cout<<cnt;
29+
return 0;
30+
}

BaekJoon/2908_상수.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
#include <iostream>
3+
#include <string>
4+
#include <algorithm>
5+
using namespace std;
6+
7+
int main() {
8+
string first;
9+
string second;
10+
cin>>first>>second;
11+
reverse(first.begin(), first.end());
12+
reverse(second.begin(), second.end());
13+
if(stoi(first) > stoi(second)) cout<<first;
14+
else cout<<second;
15+
return 0;
16+
}

BaekJoon/5622_다이얼.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int dial(char c) {
5+
int val = (int)c -65;
6+
if(val/3 == 0) return 3;
7+
if(val/3 == 1) return 4;
8+
if(val/3 == 2) return 5;
9+
if(val/3 == 3) return 6;
10+
if(val/3 == 4) return 7;
11+
if(15<= val && val<=18) return 8;
12+
if(19<= val && val<=21) return 9;
13+
if(22<=val && val<=25) return 10;
14+
return 0;
15+
}
16+
int main() {
17+
string input;
18+
Cin >> input;
19+
int time = 0;
20+
for(int i=0; i<input.length(); i++) {
21+
time += dial(input[i]);
22+
}
23+
cout<<time;
24+
return 0;
25+
}

BaekJoon/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ https://www.acmicpc.net/
3737
|**1330**|**두 수 비교하기**|2020.04.26|1|
3838
|**14681**|**사분면 고르기**|2020.04.26|1|
3939
|**1152**|**단어의 개수**|2020.08.15|1|
40-
|****|****|||
41-
|****|****|||
42-
|****|****|||
40+
|**2908**|**상수**|2020.08.16|2|
41+
|**5622**|**다이얼**|2020.08.16|4|
42+
|**1316**|**크로아티아 알파벳**|2020.08.16|2|
4343
|****|****|||
4444
|****|****|||
4545
|****|****|||

0 commit comments

Comments
 (0)