10分求助

P2669 [NOIP2015 普及组] 金币

Miracle_InDream @ 2023-09-02 18:11:51

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,coin1=0,coin2=2,day=1,day2=2;
    cin>>n;
    for(day=1;day<=n;day++){
        if(day!=day2){
            coin1+=coin2-1;
        }
        else{
            coin1+=coin2;
            coin2++;
            day2+=coin2;
        }
    }
    cout<<coin1;
    return 0;
}

by liaiyang @ 2023-09-02 18:15:54

coin2++和day2+=coin2语句交换位置


by liaiyang @ 2023-09-02 18:21:00

@liyirong567


|