Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<iostream>
- #include<cmath>
- #include<iomanip>
- #include<algorithm>
- #include<cstdlib>
- #include<cstring>
- #include<vector>
- #include<utility>
- using namespace std;
- #define ll long long
- #define nl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(),x.end()
- #define rall(s) s.rbegin(), s.rend()
- #define getline(s) getline(cin>>ws,s)
- #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
- #define pi 3.141592653589793
- /*
- ███╗░░██╗███████╗░██████╗░███╗░░░███╗
- ████╗░██║██╔════╝██╔════╝░████╗░████║
- ██╔██╗██║█████╗░░██║░░██╗░██╔████╔██║
- ██║╚████║██╔══╝░░██║░░╚██╗██║╚██╔╝██║
- ██║░╚███║███████╗╚██████╔╝██║░╚═╝░██║
- ╚═╝░░╚══╝╚══════╝░╚═════╝░╚═╝░░░░░╚═╝
- */
- void Fast_IO(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- // freopen("filename.in", "r", stdin);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- ll n,s; cin>>n>>s;
- vector<ll>v(n);
- ll start =9;
- if((s>n*9) or (s%2== 1 and n%2 ==0)) return void (cout<<-1<<nl);
- int l=0,r=n-1, mid = n/2;
- while(s>0){
- if(s - 2*start< 0) start--;
- else{
- s -= 2*start;
- v[l++] = start;
- v[r--] = start;
- }
- if(l>=r) break;
- }
- if(s>=0 and s <=9 and n%2){
- v[mid] = s;
- s=0;
- }
- if(v[0] == 0) return void(cout<<-1<<nl);
- if(s == 0){
- for(auto i:v) cout<<i;
- cout<<nl;
- return;
- }else return void (cout<<-1<<nl);
- }
- int main(){
- Fast_IO();
- int t =1;
- cin>>t;
- while(t--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement