大佬们哪错了?怎么只有20分实在找不出来了!!!崩溃

P2669 [NOIP2015 普及组] 金币

Adore_love @ 2024-09-08 10:14:49

#include <bits/stdc++.h>
using namespace std;
int main(){
    int m;
    cin>>m; 
    bool ok=0; 
    int s1=0,s2=1;
    while(m>=s2){
        int p=s2;
        for(int i=1;i<=s2;i++){
            s1+=s2;
            p++;
            if(p>=m){
                cout<<s1;
                ok=1;
                break;
            }
        }
        if(ok) break;
        s2++;
    }
    if(ok!=1) cout<<s1;
} 

by xuyangming @ 2024-09-08 10:34:01

#include<iostream>
using namespace std;
int main()
{
    int i,n,k=0;
    cin>>n;
    int s=0;
    for( i = 1;i<=n;i++)
    {
        if(k+i>n)
        {
            break;
        }
        for(int j=1;j<=i;j++)
        {
            s+=i;
        }
        k+=i;
    }
    cout<<s+(n-k)*i<<endl;    
    return 0;
}    

by xuyangming @ 2024-09-08 10:34:55

@xuyangming 关注一下吧


by chenzhishuo2012 @ 2024-09-12 09:26:37

@yyda5203000b 求互关

#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
int k,s;
signed main(){
    cin>>k;
    for(int i=1;;i++){
        if(k<=i){
            s+=k*i;
            cout<<s<<endl;
            return 0;
        }
        k-=i;
        s+=i*i;
    }
    return 0;
}

by BlackMythology @ 2024-10-16 22:31:06

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,b=0,c=1,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        n-=i,b+=c*c,c++;
    }
    cout<<b+n*c;
    return 0;
} 

by Zhangruihang123456 @ 2024-10-19 18:52:27

#include<bits/stdc++.h>
using namespace std;
int a[10001];
int main(){
    int k;
    cin>>k;
    int day=1;
    int sum=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=i;j++){
            a[day]=i;
            sum+=a[day];
            if(day==k){
                cout<<sum;
                return 0;
            }
            day++;
        }
    }
    return 0;
}

|