简要题意:
构造一个长为 n n n 的数,使得每位均不为 0 0 0,且 n n n 不被它的各位数字整除。
比方说, n = 239 n = 239 n=239 是合法的。因为:
2 ∤ 239 2 \not | 239 2∣239, 3 ∤ 239 3 \not | 239 3∣239, 9 ∤ 239 9 \not | 239 9∣239.
再比方, n = 235 n = 235 n=235 是不合法的。因为:
5 ∣ 235 5 | 235 5∣235.
因此,本题是个水构造。
首先 n = 1 n = 1 n=1,显然无解。
否则,考虑以下构造:
233 ⋯ 33 233 \cdots 33 233⋯33
499 ⋯ 99 499 \cdots 99 499⋯99
277 ⋯ 77 277 \cdots 77 277⋯77
577 ⋯ 77 577 \cdots 77 577⋯77
599 ⋯ 99 599 \cdots 99 599⋯99
899 ⋯ 99 899 \cdots 99 899⋯99
677 ⋯ 77 677 \cdots 77 677⋯77
⋯ \cdots ⋯
(盲猜不下 1000 1000 1000 种构造,全部合法)
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
inline int read(){char ch=getchar();int f=1;while(ch<'0' || ch>'9') {if(ch=='-') f=-f; ch=getchar();}
int x=0;while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();return x*f;}
int main(){
int T=read(); while(T--) {
int n=read();
if(n==1) printf("-1\n");
else {
putchar('4');
for(int i=1;i<n;i++) putchar('9');
putchar('\n');
} //499...99
}
return 0;
}