题解

· · 题解

思路

这题你很蒙吗?

看看测试点吧!

测试点

原版
1 5 4 ->1 1 1 1 1
2 3 8 ->2 2 3
1 5 10 ->1 1 1 7 7
2 6 34 ->1 1 4 5 1 4
1 3 1 ->-1

许多测试点都有1,所以...

改进版
1 5 4 ->1 1 1 1 1
2 3 8 ->1 1 7
1 5 10 ->1 1 1 7 7
2 6 34 ->1 1 1 1 1 30
1 3 1 ->-1

np=1->至少n-2个1

np=2->至少n-1个1

x-n+2<0 -> -1

初步调试

#include<iostream>
using namespace std;
int main(){
    int k;
    cin>>k;
    for(int i=1;i<=k;i++){
        int op,n,x;
        cin>>op>>n>>x;
        if(x-n+2>0){
            for(int i=0;i<=n-3;i++){
                cout<<1<<" ";
            }
            if(op==1){
                ?
            }
            if(op==2){
                cout<<1<<" "<<?<<endl;
            }
            continue;
        }
        cout<<-1<<endl;

    }
    return 0;
}

再调试

其他的数相等,是x-n+2

#include<iostream>
using namespace std;
int main(){
    int k;
    cin>>k;
    for(int i=1;i<=k;i++){
        int op,n,x;
        cin>>op>>n>>x;
        if(x-(n-2)>0){
            for(int i=0;i<=n-3;i++){
                cout<<1<<" ";
            }
            if(op==1){
                cout<<x-n+2<<" "<<x-n+2<<endl;
            }
            if(op==2){
                cout<<1<<" "<<x-n+2<<endl;
            }
            continue;
        }
        cout<<-1<<endl;

    }
    return 0;
}

谢谢!