栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

CodeForces - 1594A Consecutive Sum Riddle【数学计算】

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CodeForces - 1594A Consecutive Sum Riddle【数学计算】

A. Consecutive Sum Riddle
time limit per test 2 seconds
memory limit per test 256 megabytes

Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).

You are given an integer n. You need to find two integers l and r such that −1018≤l18 and l+(l+1)+…+(r−1)+r=n.

Input
The first line contains a single integer t (1≤t≤104) — the number of test cases.

The first and only line of each test case contains a single integer n (1≤n≤1018).

Output
For each test case, print the two integers l and r such that −1018≤l18 and l+(l+1)+…+(r−1)+r=n.

It can be proven that an answer always exists. If there are multiple answers, print any.

Example
input
7
1
2
3
6
100
25
3000000000000
output
0 1
-1 2
1 2
1 3
18 22
-2 7
999999999999 1000000000001

Note
In the first test case, 0+1=1.

In the second test case, (−1)+0+1+2=2.

In the fourth test case, 1+2+3=6.

In the fifth test case, 18+19+20+21+22=100.

In the sixth test case, (−2)+(−1)+0+1+2+3+4+5+6+7=25.

问题链接:CodeForces - 1594A Consecutive Sum Riddle
问题简述:(略)
问题分析:(略)

AC的C语言程序如下:


#include 

int main()
{
    int t;
    scanf("%d", &t);
    while (t--) {
        long long n;
        scanf("%lld", &n);
        printf("%lld %lldn", -n + 1, n);
    }
    
    return 0;
}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/879186.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号