-
-
Notifications
You must be signed in to change notification settings - Fork 300
/
441.cpp
28 lines (27 loc) · 782 Bytes
/
441.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
__________________________________________________________________________________________________
sample 4 ms submission
class Solution {
public:
int arrangeCoins(int n) {
return (sqrt(1. + 8.*n) - 1)/2.;
}
};
__________________________________________________________________________________________________
sample 8260 kb submission
class Solution {
public:
int arrangeCoins(int n) {
int count = 0;
for (int i = 1; n > 0; ++i) {
n -= i;
if (n >= 0) ++count;
}
return count;
}
};
static const auto __ = []() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
return nullptr;
}();
__________________________________________________________________________________________________