๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/๋ฐฑ์ค€(BOJ)

[๋ฐฑ์ค€,c++] 1356๋ฒˆ - ์œ ์ง„ ์ˆ˜

by dkswnkk 2021. 11. 4.
 

1356๋ฒˆ: ์œ ์ง„์ˆ˜

์ฒซ์งธ ์ค„์— ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค. ์ด ์ˆ˜๋Š” 2,147,483,647๋ณด๋‹ค ์ž‘๊ฑฐ๋‚˜ ๊ฐ™์€ ์ž์—ฐ์ˆ˜์ด๋‹ค.

www.acmicpc.net

#include <iostream>
#include <string>
using namespace std;
bool check;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string N; cin >> N;

    int tempLeft = 1;
    for (int i = 0; i < N.length()-1; i++) {
        int tempRight = 1;
        tempLeft *= (N[i]-'0');
        for (int k = i + 1; k < N.length(); k++) {
            tempRight *= (N[k] - '0');
        }
        if (tempLeft == tempRight) {
            check = true;
            break;
        }
    }
        if (check) cout << "YES";
        else cout << "NO";
}

๋Œ“๊ธ€