Recent Posts
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- JanusWebRTCGateway
- vfr video
- preemption #
- JanusWebRTCServer
- terminal
- pytest
- table not found
- JanusGateway
- 겨울 부산
- 자원부족
- 깡돼후
- 달인막창
- 헥사고날아키텍처 #육각형아키텍처 #유스케이스
- 티스토리챌린지
- JanusWebRTC
- 개성국밥
- 코루틴 컨텍스트
- mp4fpsmod
- k8s #kubernetes #쿠버네티스
- taint
- 코루틴 빌더
- Value too long for column
- Spring Batch
- tolerated
- VARCHAR (1)
- PytestPluginManager
- PersistenceContext
- python
- 오블완
- kotlin
Archives
너와 나의 스토리
Codeforces Round #565 (Div. 3) 본문
반응형
A - Divide it!
int tc;
long long n;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> tc;
while (tc--) {
cin >> n;
long long cnt = 0;
bool frag = true;
while (n > 1) {
if (n % 2 == 0) n /= 2;
else if (n % 3 == 0) n=n/3*2;
else if (n % 5 == 0) n=n/5*4;
else {
frag = false;
break;
}
cnt++;
}
if (!frag) cout << "-1\n";
else cout << cnt << '\n';
}
return 0;
}
B - Merge it!
입력을 3의 나머지로만 연산
(1,2) (1,1,1) (2,2,2)일 때 3의 배수로 만들 수 있음
int tc,n;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> tc;
while (tc--) {
cin >> n;
int arr[3] = { 0,0,0 };
int cnt = 0;
for (int i = 0; i < n; i++){
int q;
cin >> q;
arr[q % 3]++;
}
cnt += arr[0];
if (arr[1] < arr[2]) {
cnt += arr[1];
cnt += (arr[2] - arr[1]) / 3;
}
else {
cnt += arr[2];
cnt += (arr[1] - arr[2]) / 3;
}
cout << cnt << '\n';
}
return 0;
}
C - Lose it!
int arr[7] = {0,4,8,15,16,23,42}, n, pos;
map<int,int> s;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
cin >> n;
int cnt = 0;
map<int,int> m;
for (int i = 0; i < 7; i++) {
m[arr[i]] = i;
}
s[0] = 500000;
for (int i = 0; i < n; i++) {
int w;
cin >> w;
if (w == 42) {
if (s[m[w] - 1] == 0) cnt++;
else s[m[w] - 1]--;
continue;
}
if (s[m[w] - 1] == 0) cnt++;
else{
s[m[w]-1]--;
s[m[w]]++;
}
}
int t = 0;
for (auto i : s) {
cnt += i.first*(i.second);
}
cout << cnt;
return 0;
}
반응형
'Algorithm > Codeforces' 카테고리의 다른 글
Educational Codeforces Round 101 (Rated for Div. 2) 풀이 (0) | 2020.12.31 |
---|---|
Codeforces Round #686 (Div. 3) 풀이 (0) | 2020.12.13 |
Codeforces Round #615 (Div. 3) (0) | 2020.03.22 |
Codeforces Round #575 (Div. 3) (0) | 2019.07.28 |
Comments