#8WA 求助大佬大佬

P2669 [NOIP2015 普及组] 金币

Lanlanshigeder @ 2022-03-02 17:20:17


#include <iostream>
using namespace std;
int a[10010]={0};

int main() 
{
    int k,n=1,s=0;
    cin>>k;
    for(int i=1;i<=110;i++)
      for(int j=1;j<=i;j++)
        a[n++]=i;
    for(int i=1;i<=k;i++)
      s=s+a[i];
    cout<<s<<endl;
    return 0;
}

by sprads @ 2022-03-02 17:28:35

@Lanlanshigeder 开 long long


by Lanlanshigeder @ 2022-03-02 17:34:24

@sprads 还是WA呜呜


by sprads @ 2022-03-02 17:39:34

@Lanlanshigeder

\dfrac{111 \times 110}{2}=6105 < 10^4

by Lanlanshigeder @ 2022-03-02 17:52:00

@sprads 谢谢谢谢


|