문제 링크입니다: https://www.acmicpc.net/problem/8558
8558번: Silnia
Niech n będzie nieujemną liczbą całkowitą. Liczbę n! (czytaj n-silnia) definiuje się następująco. Jeśli n ≤ 1, to n! = 1. Dla n > 1, n! jest równe iloczynowi wszystkich liczb od 1 do n, czyli n! = 1 * 2 * ... * n. Na przykład 4! = 1 * 2
www.acmicpc.net
간단한 구현 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int n; | |
cin >> n; | |
int result = 1; | |
for (int i = 2; i <= n; i++) | |
{ | |
result *= i; | |
result %= 10; | |
} | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 21645번 Ролевая игра (0) | 2021.06.27 |
---|---|
백준 8658번 Liczba (0) | 2021.06.26 |
백준 8320번 직사각형을 만드는 방법 (0) | 2021.06.26 |
백준 8295번 Rectangles (0) | 2021.06.26 |
백준 8426번 Stół (0) | 2021.06.26 |