为什么答案错误啊

P2669 [NOIP2015 普及组] 金币

nuclear @ 2016-09-19 22:40:51

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
void init(){
    int n;
    int ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(n>i){
            ans+=i*i;
            n-=i;
        }else{
            ans+=n*i;
            break;
        }
        printf("%d",ans);
    }
    return ;
}
int main(){
    init();
    return 0;
}

by ghj1222 @ 2016-09-19 22:45:25

约瑟夫


by nuclear @ 2016-09-19 22:47:52

为啥


by dragon_bra @ 2016-09-20 00:19:23

。。这怎么可能是对的呢。。


by nuclear @ 2016-09-20 13:38:40

怎么不对呢


by tututu @ 2016-10-29 16:43:13

+2


|