1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<iostream> using namespace std; int main() { int n, sum, max; while (cin >> n) { sum = 0; max = 0; for (int i = 1; i <= n; i++) { if (sum + i > n) break; sum += i; max++; } cout << max << endl; } return 0; } |
沒有留言:
張貼留言