对于这道题,我们需要把最多 \(100\) 个 \(1\) 组成一个式子,使得这个式子的结果为 \(k\)。
由于出题人很穷,只给了 \(100\) 个 \(1\)。那么,对于 \(k \le 100\) 的情况就直接用 \(k\) 个 \(1\) 累加起来即可。
然后,我们来考虑 \(k\) 的值超过 \(100\) 该如何。
因为我们可以进行乘法操作,所以我们考虑分解因数。但是,又有一个困难摆在我们面前,对于大质数我们无法处理。但是我们将大质数减一,这个大质数就会成为一个合数。这是因为质数中只有 \(2\) 是偶数,其余都为奇数。
所以,用这个方法,我们可以把大质数、因数里含大质数的 \(k\) 处理出来。
由于增长量是 \(\log\) 级别的,所以在 \(10^9\) 范围之内一定能表示出所有数,所以不存在无解。
下面是代码环节:
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define FIOBUFSIZ 1048576
#define NEGATIVE
struct freader {FILE*f;
# ifdef ONLINE_JUDGEchar buf[FIOBUFSIZ], *p1, *p2;
# define fgetc(f) (p1==p2&&(p2=(p1=buf)+fread(buf,1,FIOBUFSIZ,f),p1==p2)?EOF:*p1++)
# endif
# ifdef BOOLTRANSbool neof;
# define NEOF(c) ((c)!=EOF||(neof=0))
# else
# define NEOF(c) ((c)!=EOF)
# endif
# ifdef NOTONLYDIGIT
# define isdigit(c) ((c)>='0'&&(c)<='9')
# define isnotdigit(c) ((c)<'0'||(c)>'9')
# else
# define isdigit(c) ((c)>='0')
# define isnotdigit(c) ((c)<'0')
# endiffreader(FILE*_f = stdin): f(_f) {
# ifdef BOOLTRANSneof = 1;
# endif
# ifdef ONLINE_JUDGEsetvbuf(f, NULL, _IONBF, 0);p1 = p2 = buf;
# endif}
# ifdef NOTONLYDIGITvoid read(char&x) {for (x = fgetc(f); NEOF(x) && x <= ' '; x = fgetc(f));return;}void read(char*s) {for (*s = fgetc(f); NEOF(*s) && *s <= ' '; *s = fgetc(f));for (s++; NEOF(*s = fgetc(f)) && *s > ' '; s++);*s = '\0';return;}freader&operator>>(char*x) {
# ifdef BOOLTRANSreturn *this ? read(x), *this : *this;
# elsereturn read(x), *this;
# endif}
# endiftemplate<typename T>void read(T&x) {char c(fgetc(f));
# ifdef NEGATIVEfor (; NEOF(c) && isnotdigit(c) && c != '-'; c = fgetc(f));if (c == '-')for (c = fgetc(f), x = 0; NEOF(c) && isdigit(c); c = fgetc(f))x = (x << 3) + (x << 1) - (c^'0');elsefor (x = 0; NEOF(c) && isdigit(c); c = fgetc(f))x = (x << 3) + (x << 1) + (c^'0');
# elsefor (; NEOF(c) && isnotdigit(c); c = fgetc(f));for (x = 0; NEOF(c) && isdigit(c); c = fgetc(f))x = (x << 3) + (x << 1) + (c^'0');
# endifreturn;}void ignore() {char c(fgetc(f));for (; NEOF(c) && c <= ' '; c = fgetc(f));for (; NEOF(c) && c > ' '; c = fgetc(f));return;}
# if __cplusplus>=201103template<typename T, typename...Args>void read(T&x, Args&...args) {return read(x), read(args...);}
# endiftemplate<typename T>freader&operator>>(T&x) {
# ifdef BOOLTRANSreturn *this ? read(x), *this : *this;
# elsereturn read(x), *this;
# endif}
# ifdef BOOLTRANSoperator bool() {return neof;}
# endif
# ifdef ONLINE_JUDGE
# undef fgetc
# endif
# undef NEOF
# undef isdigit
# undef isnotdigit
} fin;
struct fwriter {FILE*f;
# ifdef ONLINE_JUDGEchar buf[FIOBUFSIZ], *p1;
# define fputc(c,f) (p1==buf+FIOBUFSIZ?fwrite(buf,1,FIOBUFSIZ,f),*(p1=buf)++=(c):*p1++=(c))
# endiffwriter(FILE*_f = stdout): f(_f) {
# ifdef ONLINE_JUDGEsetvbuf(f, NULL, _IONBF, 0);p1 = buf;
# endif}~fwriter() {flush();}void flush() {
# ifdef ONLINE_JUDGEfwrite(buf, 1, p1 - buf, f), p1 = buf;
# elsefflush(f);
# endifreturn;}void write(char c) {fputc(c, f);return;}void write(char*s) {for (; *s; s++)fputc(*s, f);return;}void write(const char*s) {for (; *s; s++)fputc(*s, f);return;}template<typename T>void write(T x) {if (!x) {fputc('0', f);return;}if (x < 0)fputc('-', f), x = -x;char s[41];int l(0);while (x)s[l++] = x % 10 ^ '0', x /= 10;while (l--)fputc(s[l], f);return;}
# if __cplusplus>=201103template<typename T, typename...Args>void write(T x, Args...args) {return write(x), write(args...);}
# endiftemplate<typename T>fwriter&operator<<(T x) {return write(x), *this;}
# ifdef ONLINE_JUDGE
# undef fputc
# endif
} fout;
int t, k;
string ans;
void dfs(int u) {if (u == 1) {
// ans += '1';fout << '1';return;}
// ans += '(';fout << '(';for (int i = 2; i * i <= u; i ++) {if (u % i == 0) {dfs(i);
// ans += '*';fout << '*';dfs(u / i);
// ans += ')';fout << ')';return;}}
// ans += '1';
// ans += '+';fout << '1';fout << '+';dfs(u - 1);
// ans += ')';fout << ')';
}
signed main() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);fin >> t;while (t --) {fin >> k;if (k <= 100) {for (int i = 1; i < k; i ++) {fout << '1';fout << '+';} fout << '1';fout << '\n';continue;} dfs(k);
// int len = ans.size();
// for (int i = 0; i < len; i ++) {
// fout << ans[i];
// }fout << "\n";}return 0;
}
