1. 题目分析
阅读理解题。
设 且符合题意,分情况讨论。
-
当 时,输出 和 。
-
当 时,输出 和 。
因为 在三位数以内,所以这样也可以限制 和 在三位数以内。
但考虑情况不完整,当 或 时,上述方案并不成立,这是我们不妨特判,选择你喜欢的数字输出就好了。
2. 代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int s;
scanf("%d",&s);
if(s==1)printf("-1 2\n");
else if(s==-1)printf("1 -2\n");
else if(s>=0)printf("%d %d\n",1,s-1);
else printf("%d %d\n",-1,s+1);
return 0;
}