题解:P14495 [NCPC 2025] Arithmetic Adaptation

· · 题解

题面解释

此题要求输出满足以下要求的值。

题目分析

首先,贪心地想,我们先确定一件事:除了两个数,其余的都可以用 a=1,b=s-1 表示,这两个数分别是 -999,1

那么,这两个数特判一下就好了。

#include<bits/stdc++.h>
using namespace std;
int s;
int main(){
    cin>>s;
    if(s==-999) cout<<-1<<' '<<s-(-1);//特判-999
    else if(s==1) cout<<"-1 2";//特判1
    else cout<<1<<' '<<s-1;
    return 0;
}