BH3rd @ 2023-03-13 16:17:56
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k;
int n=0;
cin>>k;
for(int i=1;i<=k;i++)
{
for(int j=1;j<=i;j++)
{
n=n+i;
}
}
cout<<n;
return 0;
}
by dwylyz @ 2023-03-13 16:28:28
这……你这是在第i天加i^2元吧
by Zpril_20211017 @ 2023-03-13 16:29:38
请计算在前
k 天里,骑士一共获得了多少金币。
题目是说k天,不是发放k枚金币(
by Zpril_20211017 @ 2023-03-13 16:33:34
参考我代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,cnt = 0,i;
cin >> n;
for(i = 1;i <= n;i++)
{
n -= i;
cnt += i * i;
}
cout << cnt + n * i;
return 0;
}
by BH3rd @ 2023-03-13 16:45:24
@Zpril
谢谢大佬