문제 : 검증수(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)'(구) solved ac class 문제들 > class 1' 카테고리의 다른 글
| [class 1]백준 구구단(2739번) 풀이 (C++/Python) (0) | 2026.02.06 |
|---|---|
| [class 1]백준 Hello World(2557번) (C++/Python) (0) | 2026.02.05 |
| [class 1]백준 별 찍기 - 1(2438번) (C++/Python) (0) | 2026.02.04 |
| [class 1]백준 두 수 비교하기(1330번) (C++/Python) (0) | 2026.02.03 |
| [class 1]백준 A/B(1008번) 풀이 (C++/Python) (0) | 2026.01.30 |