求帮助

P2669 [NOIP2015 普及组] 金币

Etic_HAO @ 2022-06-17 20:49:44

9个wa

求帮助 代码:


#include <iostream>

using namespace std;

  int main(){

  int k,q,c,s;

  cin>>k;

  c=q=1;    

  for(int i=1;i<=k;i++){

        s+=c;

        q--;    

            if(q==0){

            c++;    
            q=c;    
        }
    }
    cout<<s;    
    return 0;   
}

by jdhff @ 2022-06-17 20:55:43

这不是10个WA吗


by Etic_HAO @ 2022-06-17 21:09:14

@jdhff 不太清楚了


by jdhff @ 2022-06-17 21:10:09

我刚试了一下


by jdhff @ 2022-06-17 21:15:59

@Etic_HAO可以参考一下题解(温馨提示:不要抄)


by jdhff @ 2022-06-17 21:17:56

@Etic_HAO


by Etic_HAO @ 2022-06-19 19:19:19

我懂了

@jdhff

我懂了

我没定义s=0!!!


by jdhff @ 2022-06-20 11:58:48


|