【NOIP2015普及组】金币
作业之考试n
#include<bits/stdc++.h>
using namespace std;
long long l,m,n;
int main(){
// freopen(“coin.in”,“r”,stdin);
// freopen(“coin.out”,“w”,stdout);
scanf("%lld",&n);
for(int z=1;z<=n;){
++m;
for(int y=1;y<=m&&z<=n;++y,++z) l+=m;
}
printf("%lld",l);
}
z为天数,m为第z天发的金币数和持续时间,外层循环z不增加因为内层循环有了,内外层循环都要加限制条件避免z过n天。

相关文章:

  • 2022-01-03
  • 2021-12-05
  • 2022-02-08
  • 2022-02-08
  • 2022-02-08
  • 2022-02-08
  • 2022-01-25
  • 2021-05-18
猜你喜欢
  • 2021-07-20
  • 2021-10-27
  • 2021-06-21
  • 2021-04-07
  • 2021-03-31
相关资源
相似解决方案