CSP-J 2024.10
创建两个数组dx和dy,存储对应d的x,y值变化,避免一堆if
void Solve(int x){string res;bool first = true;while (x){int t = -1;for (int j = 0; j <= 9; j++){if (x >= a[j] && f[x] == f[x - a[j]] + 1){ // 能够摆出数字if (first && !j){ // 首位不能为0continue;}first = false;t = j;break;}}if (t == -1){cout << -1 << endl;return;}res += t + '0';x -= a[t];}cout << res << endl;
}