| //https://www.acmicpc.net/problem/2998 #include <iostream> |
| #include <string> |
| using namespace std; |
| int main() |
| { |
| string bin; |
| cin >> bin; |
| int l=bin.size(); |
| int x; |
| int r=l%3; |
| if(r==1) cout << "1"; |
| if(r==2) |
| { |
| if((bin[1]-'0')==0) cout << "2"; |
| else cout << "3"; |
| } |
| for(int i=r; i<l; i+=3) |
| { |
| x=(bin[i]-'0')*4+(bin[i+1]-'0')*2+(bin[i+2]-'0'); |
| if(x==0) cout << "0"; |
| else if(x==1) cout << "1"; |
| else if(x==2) cout << "2"; |
| else if(x==3) cout << "3"; |
| else if(x==4) cout << "4"; |
| else if(x==5) cout << "5"; |
| else if(x==6) cout << "6"; |
| else cout << "7"; |
| } |
| } |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
| 171228_2167_2차원 배열의 합 (0) | 2017.12.28 |
|---|---|
| 171227_2563_색종이 (0) | 2017.12.27 |
| 171225_12790_Mini Fantasy War (0) | 2017.12.25 |
| 171224_1789_수들의 합 (0) | 2017.12.24 |
| 171224_10886_0 = not cute / 1 = cute (0) | 2017.12.24 |