chenzixuan_06 @ 2024-11-04 21:36:33
#include<iostream>
using namespace std;
int n;
unsigned long long money(int m);
int day(int n);
int main(void)
{
cin>>n;
cout<<money(n);
}
int day(int n)
{ int sum=0;int a;
for(int i=1;i<=n;i++)
{
if(sum+i>n)
{
a=i-1;break;}
sum+=i;
}
return a;
}
unsigned long long money(int m)
{
unsigned long long money=0;int day1=day(n);
for(int t=1;t<=day1;t++)
{
money+=t*t;
}
money=money+(n-(1+day1)*day1/2)*(day(n)+1);
return money;
}
by szmqi @ 2024-11-08 20:22:56
#include <bits/stdc++.h>
using namespace std;
int main(){
int s=0,n,x=0,a=1;
cin>>n;
while(n>0){
x+=a;
s++;
if(s==a){
a++; s=0;
}
n--;
}
cout<<x;
return 0;
}
by liujihan @ 2024-11-08 20:30:56
#include<iostream>
using namespace std;
int main(){
int k,coin = 0,day = 0;
cin << k;
for(int i = 1;;i++)
for(int j = 1;j <= i;j++){
coin += i;days++;
if(day == k){
cout << coin << endl;
return 0;
}
return 0;
}