(구) solved ac class 문제들/class 1

[class 1]백준 검증수(2475번) (C++/Python)

isekaipudding 2026. 2. 5. 11:07

문제 : 검증수(2475번)(Bronze V)

문제 링크 : https://www.acmicpc.net/problem/2475
출처 : Baekjoon Online Judge

 

이 문제의 답을 수학 공식으로 표현하면 다음과 같습니다.

$$\text{answer} = (a^2 + b^2 + c^2 + d^2 + e^2)\bmod 10$$

이것을 C++ 및 Python으로 구현합니다.

[C++]

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    cout << (a * a + b * b + c * c + d * d + e * e) % 10;
 
    return 0;
}

[Python]

import sys

input = sys.stdin.readline

a, b, c, d, e = map(int, input().split())
print((a * a + b * b + c * c + d * d + e * e) % 10)