← Back to List

15719번: 중복된 숫자 ↗

Solutions

C++14
248 B | 248 chars
#include <iostream>
using namespace std;
long long N,S,a;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    cin>>N;
    for(int x=0; x<N; x++)
    {
        cin>>a;
        S+=a;
    }
    cout<< abs(S - N*(N-1)/2);
}