본문 바로가기
반응형

SWE/코테137

[SW Expert Academy] '10' #1225 암호 생성기 X 단순 작업 반복으로 풀려고 했는데 test case에서 주어진 숫자가 컸다. 그래서 몇 회 돌면 반복되는지 규칙성을 찾았다. => 8 cycle돌면 숫자의 순서가 처음 순서와 같아지고, 감소되는 값도 모두 -15으로 같다는 걸 확인할 수 있다. 즉, 입력받은 값이 15이상이면 모두 15의 배수를 빼고 시뮬레이션하면서 결과값을 알 수 있다. // #1225 암호생성기 #include #include //cin >> str #include //memset using namespace std; int main(void) { int arr[8]; for(int tc=1; tc >tc; int minimum = 987654321; // 가장 작은 몫.. 2019. 3. 14.
[SW Expert Academy] '9' #1221 GNS X 쉬움,,, // #1221 GNS #include #include using namespace std; string num[10]={"ZRO", "ONE", "TWO", "THR", "FOR", "FIV", "SIX","SVN", "EGT", "NIN"}; int cnt[10]={0,}; int main(void) { int tc; cin >> tc; for(int tc=1; tc> temp_str >> sz; for(int i=0; i > temp_str; // 입력받기 for(int k=0; k< 10; k++){ // 숫자 count++ if(temp_str == num[k]){ cnt[k]++; } } } // 출력 cout 2019. 3. 13.
[SW Expert Academy] '8' #1220 Magnetic X 처음에는 시뮬레이션 문제인줄 알았는데, 그냥 갯수 세는 count문제이다. 한 열씩, 위에서 아래로 내려오면서 1과 2가 순서대로 있을 경우 count를 하나 늘려주면서 풀면 된다. // #1220 Magnetic #include #include using namespace std; int main(void) { int arr[100][100]; for(int tc=1; tc> sz; for(int r=0; r > arr[r][c]; } } int answer =0; for(int c=0; c< sz; c++){ bool flag = false; for(int r=0; r< sz; r.. 2019. 3. 13.
[SW Expert Academy] '7' #1217 거듭제곱 X 이거 6일차 공부라고 쓰기 양심에 찔림... 엄청난 기초... 재귀함수로 풀라는 조건이 없었다면 (문제 pass fail 에는 상관없을테지만) 반복문으로 푸는게 더 빠르고 stack사용 부분에서도 더 효율적이지 않았을까 // #1217 거듭제곱 #include #include using namespace std; int answer; void func(int _num, int _cnt){ // 탈출조건 if(_cnt==0){ return; } answer *= _num; _cnt--; func(_num,_cnt); } int main(void) { for(int tc=1; tc>tc; answer = 1;//초기화 int num,cnt; cin>>num>>cnt.. 2019. 3. 13.
반응형