不知道为什么把;改成,就对了(看了眼题解发现要改成,

P2669 [NOIP2015 普及组] 金币

Unaccepted_Error @ 2022-10-08 16:43:19

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

为什么下面错上面对?

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

by Unaccepted_Error @ 2022-10-08 16:52:33

简单的题目只需要大佬的回答()


by Cubic @ 2022-10-08 16:58:59

@S11EDG why?


by qwqszxc45rtnhy678ikj @ 2022-10-08 17:05:01

话说楼主是写python出身的吗?是不是错以为也是缩进(我不会python,不是很了解


by Unaccepted_Error @ 2022-11-05 15:39:48

@ZZP_AK_IOI 只是因为蒻吧(py没怎么学)


上一页 |