-
[14607] 피자 (Large)BOJ 2022. 5. 13. 20:46
https://www.acmicpc.net/problem/14607
14607번: 피자 (Large)
예제1의 입력이 1이므로, 게임 시작부터 갑이 분리할 수 있는 피자탑이 없습니다. 따라서 갑이 얻는 즐거움은 0입니다. 예제2의 정답 3은 다음과 같은 과정을 통해 얻어집니다. 먼저 놀이를 시작
www.acmicpc.net
초기항 몇개를 직접 계산해보면, 규칙성이 보인다.
#include <bits/stdc++.h>using namespace std;#ifdef ONLINE_JUDGEconstexpr bool local = false;#elseconstexpr bool local = true;#endifusing ll = long long;using pi = pair<ll, ll>;int main(void) {if (!local) ios_base::sync_with_stdio(0), cin.tie(0);ll n;cin >> n;n--;cout << n * (n + 1) / 2LL;return 0;}
'BOJ' 카테고리의 다른 글
[17413] 단어 뒤집기 2 (0) 2022.05.14 [17485] 진우의 달 여행 (Large) (0) 2022.05.14 [2312] 수 복원하기 (0) 2022.05.02 [1283] 단축키 지정 (0) 2022.05.02 [24445] 알고리즘 수업 - 너비 우선 탐색 2 (0) 2022.05.02