Skip to content

A. Consecutive Sum Riddle (CF1594 800 RATED)

Published:

Problem Link: A. Consecutive Sum Riddle, 800 RATED - Codeforces Round 747 (Div. 2)

Approach

Sum of negative of n-1 to +n is equals to n.

Code Implementation

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int t;
    cin >> t;

    while (t--) {
        int n; 
        cin >> n;
        cout << -(n - 1) << " " << n << endl;
    }

    return 0;   
}

Previous Post
A. Halloumi Boxes (CF1903 800 RATED)