1 solutions
-
0
C++ :
#include<iostream> using namespace std; int main() { int k; int i = 0; int a = 0,b=0; cin >> k; while(b<=k) { ++i; a+=i*i; b=(i+1)*i/2; } a=a-(b-k)*i; cout << a<<endl; return 0; }
Python :
a=int(input()) if a>=1 and a<=10000: coins=0 days=0 daystrue=0 tof=1 while daystrue<=a: days+=1 for i in range(days): if daystrue<a: coins+=days daystrue+=1 else: tof=0 break if tof==0: break print(coins)
- 1
Information
- ID
- 9193
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By