Codeforces 1326A Bad Ugly Numbers (思维)

Codeforces 1326A Bad Ugly Numbers

看完题目,第一直觉,质数肯定满足题意,再看数据范畴,(1≤n≤10^5),

质数线性筛仅能做到 n=7 的情况,即处理到10000000.

重新读题,发现是一道构造。

(n != 1)时,另首位为(2),其他均为(9)即可

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, a[N], i, j;
void solve() {
    cin >> n;
    if (n == 1)cout << -1 << endl;
    else {
        cout << 2;
        for (i = 1; i < n; ++i)
            cout << 9;
        cout << endl;
    }
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t; cin >> t;
    while (t--)solve();
}