[SWEA] 6190 정곤이의 단조 증가하는 수

Time Lapse :29min 50sec

6190.cpp

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
29
30
31
#include <stdio.h>
inline bool is_Danjo(int num){
while(num){
if(num%10<(num/10)%10)
return false;
num/=10;
}
return true;
}
int main(int argc, char** argv)
{
register int test_case, i, j, answer;
int nums[1000];
int T,N;
scanf("%d",&T);
for (test_case = 1; test_case <= T; test_case++){
scanf("%d",&N);
answer = -1;
for(i=0;i<N;i++)
scanf("%d",&nums[i]);

for(i = 0; i<N-1; i++)
for(j = i+1; j<N; j++) {
if(answer > nums[i] * nums[j])
continue;
answer = is_Danjo(nums[i]*nums[j]) ? nums[i]*nums[j] : answer;
}
printf("#%d %d\n",test_case,answer);
}
return 0; //정상종료시 반드시 0을 리턴해야 합니다.
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/6190/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.