1 solutions

  • 1
    @ 2024-12-15 14:52:50

    叛逆的代码(没人造数据的快乐)

    #include <bits/stdc++.h>
    using namespace std;
    int n;
    long long ans = 0;
    int main () {
    	scanf("%d",&n);
    	for(int i = 1;i<=n;i++)ans+=i;
    	printf("%lld",ans);
    	return 0;
    }
    

    更叛逆的代码(不是不让用公式吗???我偏用!!!哈哈哈哈……)

    #include <bits/stdc++.h>
    using namespace std;
    int n;
    int main () {
    	scanf("%d",&n);
    	printf("%lld",(1+n)*n/2);
    	return 0;
    }
    
    
    • 1

    Information

    ID
    64
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    (None)
    # Submissions
    7
    Accepted
    3
    Uploaded By