8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6a243ae + 19b288a commit 6279fc3Copy full SHA for 6279fc3
0x12/solutions/1292.cpp
@@ -1,11 +1,23 @@
1
-// Authored by : BaaaaaaaaaaarkingDog
+// Authored by : SciEm
2
// Co-authored by : -
3
-// http://boj.kr/****************
+// http://boj.kr/2fe6deab624e4c83b409ab234ee8aa48
4
#include <bits/stdc++.h>
5
using namespace std;
6
7
-int main(void){
+int func(int n) {
8
+ int i = 1, sum = 0;
9
+ while (n > i) sum += i * i, n -= i++;
10
+ return sum + i * n;
11
+}
12
+
13
+int main() {
14
ios::sync_with_stdio(0);
15
cin.tie(0);
-
-}
16
17
+ int a, b;
18
+ cin >> a >> b;
19
+ cout << func(b) - func(a - 1);
20
21
+/*
22
+수열을 (1) (2 2) (3 3 3) ... 과 같이 묶으면 i 번째 군의 합은 i * i임을 이용했다.
23
+*/
0 commit comments