题解:P13678 [GCPC 2023] Mischievous Math

· · 题解

思路

我们可以对 d 分类讨论。当 d≥10 时,a=1,b=2,c=3 一定可以满足条件。 当 d<10 时,再求 a,b,c 就很难了。
于是,我们可以再次分类讨论。当 d3 时,我们令 a=20,b=32,c=48。当 d<10 且不为 3 时,我们令 a=19,b=31,c=47

代码

#include <bits/stdc++.h>
using namespace std;
int main() {
    int d;
    cin >> d;
    if (d >= 10) cout << "1 2 3";
    else if(d!=3) cout << "19 31 47";
    else cout<<"20 32 48";
    return 0;
}