앞에서부터 읽을 때나 뒤에서부터 읽을 때나 모양이 같은 수를 대칭수(palindrome)라고 부릅니다.

두 자리 수를 곱해 만들 수 있는 대칭수 중 가장 큰 수는 9009 (= 91 × 99) 입니다.

세 자리 수를 곱해 만들 수 있는 가장 큰 대칭수는 얼마입니까?





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
무식한게 짱..
 
#include <iostream>
#include <sstream>
 
using namespace std;
 
int main() {
    int count = 0, length = 0;
    int intval, temp = 100 * 100;
 
    for (int i = 999; i >= 100; i--) {
        count = 0;
        for (int j = 999; j >= 100; j--) {
            intval = i*j;
            count = 0;
            string str = to_string(intval);
            for (int a = 0, b = 5; a < 3; a++, b--) {
                if (str[a] == str[b])
                    count++;
                if (count == 3) {
                    if (temp < i*j)
                        temp = i*j;
                }
            }
        }
    }
    cout << temp;
}
cs


+ Recent posts