pow를 이용해 자리를 변경해줬다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <math.h> | |
/** | |
* https://www.acmicpc.net/problem/13410 | |
* BOJ 백준온라인져지 13410 거꾸로 구구단 풀이 | |
*/ | |
int MAX(int a, int b){ | |
return a > b ? a : b; | |
} | |
int main(){ | |
int N, K, max = 0; | |
scanf("%d%d", &N, &K); | |
for(int i = 1; i <= K; i++){ | |
int temp = 0; | |
int multiply = N * i; | |
temp = multiply; | |
int cnt = 0; | |
while(temp >= 10){ | |
temp /= 10; | |
cnt++; | |
} | |
temp = 0; | |
for(int j = cnt; j >= 0; j--){ | |
int f = pow(10, j); | |
int ff = multiply / f; | |
temp += ff * pow(10, cnt - j); | |
multiply %= f; | |
} | |
max = MAX(temp, max); | |
} | |
printf("%d", max); | |
} |
'IT > 알고리즘' 카테고리의 다른 글
BOJ 백준온라인져지 1916 최소비용 구하기 풀이 (0) | 2017.12.11 |
---|---|
BOJ 백준온라인져지 2702 초6 수학 풀이 (0) | 2017.12.11 |
BOJ 백준온라인져지 2711 오타맨 고창영 풀이 (0) | 2017.12.11 |
BOJ 백준온라인져지 6359 만취한 상범 풀이 (0) | 2017.12.11 |
BOJ 백준온라인져지 6378 디지털 루트 풀이 (0) | 2017.12.11 |