# ## 弱鸡的第二次线上赛总结（TKK18no.4）

## 第一题：十六进制

#include<iostream>
#include<string>
#include<cmath>
#include<bitset>
#include<algorithm>
using namespace std;
void D_TO_X(int x)
{
int i, j, arr[16];
for (i = 0; x != 0; i++)
{
arr[i] = x % 16;
if (arr[i] <= 9)
{
arr[i] += '0';
}
else
{
switch (arr[i])
{
case 10:
arr[i] = 'A'; break;
case 11:
arr[i] = 'B'; break;
case 12:
arr[i] = 'C'; break;
case 13:
arr[i] = 'D'; break;
case 14:
arr[i] = 'E'; break;
case 15:
arr[i] = 'F'; break;
}
}
x /= 16;
}
for (j = i - 1; j >= 0; j--)
{
cout.put(arr[j]);
}
cout << endl;
}

int main()
{
int n;
cin >> n;
while (n--)
{
int k;
cin >> k;
D_TO_X(k);
}
return 0;
}


## 第二题：画矩形

#include<iostream>
#include<string>
#include<cmath>
#include<bitset>
#include<algorithm>
using namespace std;

int main()
{
int m, n;
char k;
bool x;
cin >> m >> n >> k >> x;
if (x)
{
for (int i = 0; i < m; i++)
{
for (int i = 0; i < n; i++)
{
cout << k;
}
cout << endl;
}
}
else
{
for (int i = 0; i < m; i++)
{
if (i == 0 || i == m - 1)
{
for (int i = 0; i < n; i++)
{
cout << k;
}
cout << endl;
}
else
{
cout << k;
for (int i = 0; i < n-2; i++)
{
cout << " ";
}
cout << k << endl;
}
}
}
return 0;
}


## 第三题：从前有个函数

#include<iostream>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<string>
using namespace std;
bool f(int m)
{
for (int i = 2; i <= sqrt(m); i++)
{
if (m%i == 0)return 0;
}
if (m>1)return 1;
else return 0;
}

int main()
{
int n, m, p;
cin >> n;
while (n--)
{
cin >> m >> p;
while (p--)
{
if (f(m))
{
m = 2; break;
}
if (m == 1)break;
int sum = 0;
for (int i = 1; i <= sqrt(m); i++)
{
if (i*i == m)
sum++;
else if (m%i == 0)
sum += 2;
}
m = sum;
}
cout << m << endl;
}
}


## 第四题：五毒教主吃苹果

#include<iostream>
#include<string>
#include<cmath>
#include<bitset>
#include<algorithm>
using namespace std;
int t(int a, int b)
{
if (a == 0 && b == 0)return 1;
else if (b == 0)return 1;
else if (a == 0)return 1;
else return t(a - 1, b) + t(a, b - 1);
}
int main()
{
int f;
cin >> f;
while (f--)
{
int m, n;
cin >> m >> n;
cout << t(m, n) << endl;
}
return 0;
}


## 第五题：算出18

#include<iostream>
#include<string>
#include<cmath>
#include<bitset>
#include<algorithm>
using namespace std;

int main()
{
int f;
cin >> f;
while (f--)
{
double x1, x2, x3;
cin >> x1 >> x2 >> x3;
double a = x1; double b = x2; double c = x3;
int d = 0;
if (a + b + c == 18)d = 1;
else if (a + b - c == 18)d = 1;
else if (a + b * c == 18)d = 1;
else if (c!=0&&a + b / c == 18)d = 1;
else if ((a + b) * c == 18)d = 1;
else if (c != 0 && (a + b) / c == 18)d = 1;
else if (a - b + c == 18)d = 1;
else if (a - b - c == 18)d = 1;
else if (a - b * c == 18)d = 1;
else if (c != 0 && a - b / c == 18)d = 1;
else if ((a - b) * c == 18)d = 1;
else if (c != 0 && (a - b) / c == 18)d = 1;
else if (a * b + c == 18)d = 1;
else if (a * b - c == 18)d = 1;
else if (a * b * c == 18)d = 1;
else if (c != 0 && a * b / c == 18)d = 1;
else if (a * (b + c) == 18)d = 1;
else if (a * (b - c) == 18)d = 1;
else if (a / b + c == 18)d = 1;
else if (a / b - c == 18)d = 1;
else if (a / b * c == 18)d = 1;
else if (c != 0 &&b!=0&& a / b / c == 18)d = 1;
else if (b+c!=0&&a / (b + c) == 18)d = 1;
else if (b-c!=0&&a / (b - c) == 18)d = 1;
a = x2;  b = x1;  c = x3;
if (a + b + c == 18)d = 1;
else if (a + b - c == 18)d = 1;
else if (a + b * c == 18)d = 1;
else if (c != 0 && a + b / c == 18)d = 1;
else if ((a + b) * c == 18)d = 1;
else if (c != 0 && (a + b) / c == 18)d = 1;
else if (a - b + c == 18)d = 1;
else if (a - b - c == 18)d = 1;
else if (a - b * c == 18)d = 1;
else if (c != 0 && a - b / c == 18)d = 1;
else if ((a - b) * c == 18)d = 1;
else if (c != 0 && (a - b) / c == 18)d = 1;
else if (a * b + c == 18)d = 1;
else if (a * b - c == 18)d = 1;
else if (a * b * c == 18)d = 1;
else if (c != 0 && a * b / c == 18)d = 1;
else if (a * (b + c) == 18)d = 1;
else if (a * (b - c) == 18)d = 1;
else if (a / b + c == 18)d = 1;
else if (a / b - c == 18)d = 1;
else if (a / b * c == 18)d = 1;
else if (c != 0 && b != 0 && a / b / c == 18)d = 1;
else if (b + c != 0 && a / (b + c) == 18)d = 1;
else if (b - c != 0 && a / (b - c) == 18)d = 1;
a = x1; b = x3; c = x2;
if (a + b + c == 18)d = 1;
else if (a + b - c == 18)d = 1;
else if (a + b * c == 18)d = 1;
else if (c != 0 && a + b / c == 18)d = 1;
else if ((a + b) * c == 18)d = 1;
else if (c != 0 && (a + b) / c == 18)d = 1;
else if (a - b + c == 18)d = 1;
else if (a - b - c == 18)d = 1;
else if (a - b * c == 18)d = 1;
else if (c != 0 && a - b / c == 18)d = 1;
else if ((a - b) * c == 18)d = 1;
else if (c != 0 && (a - b) / c == 18)d = 1;
else if (a * b + c == 18)d = 1;
else if (a * b - c == 18)d = 1;
else if (a * b * c == 18)d = 1;
else if (c != 0 && a * b / c == 18)d = 1;
else if (a * (b + c) == 18)d = 1;
else if (a * (b - c) == 18)d = 1;
else if (a / b + c == 18)d = 1;
else if (a / b - c == 18)d = 1;
else if (a / b * c == 18)d = 1;
else if (c != 0 && b != 0 && a / b / c == 18)d = 1;
else if (b + c != 0 && a / (b + c) == 18)d = 1;
else if (b - c != 0 && a / (b - c) == 18)d = 1;
a = x2; b = x3; c = x1;
if (a + b + c == 18)d = 1;
else if (a + b - c == 18)d = 1;
else if (a + b * c == 18)d = 1;
else if (c != 0 && a + b / c == 18)d = 1;
else if ((a + b) * c == 18)d = 1;
else if (c != 0 && (a + b) / c == 18)d = 1;
else if (a - b + c == 18)d = 1;
else if (a - b - c == 18)d = 1;
else if (a - b * c == 18)d = 1;
else if (c != 0 && a - b / c == 18)d = 1;
else if ((a - b) * c == 18)d = 1;
else if (c != 0 && (a - b) / c == 18)d = 1;
else if (a * b + c == 18)d = 1;
else if (a * b - c == 18)d = 1;
else if (a * b * c == 18)d = 1;
else if (c != 0 && a * b / c == 18)d = 1;
else if (a * (b + c) == 18)d = 1;
else if (a * (b - c) == 18)d = 1;
else if (a / b + c == 18)d = 1;
else if (a / b - c == 18)d = 1;
else if (a / b * c == 18)d = 1;
else if (c != 0 && b != 0 && a / b / c == 18)d = 1;
else if (b + c != 0 && a / (b + c) == 18)d = 1;
else if (b - c != 0 && a / (b - c) == 18)d = 1;
a = x3; b = x1; c = x2;
if (a + b + c == 18)d = 1;
else if (a + b - c == 18)d = 1;
else if (a + b * c == 18)d = 1;
else if (c != 0 && a + b / c == 18)d = 1;
else if ((a + b) * c == 18)d = 1;
else if (c != 0 && (a + b) / c == 18)d = 1;
else if (a - b + c == 18)d = 1;
else if (a - b - c == 18)d = 1;
else if (a - b * c == 18)d = 1;
else if (c != 0 && a - b / c == 18)d = 1;
else if ((a - b) * c == 18)d = 1;
else if (c != 0 && (a - b) / c == 18)d = 1;
else if (a * b + c == 18)d = 1;
else if (a * b - c == 18)d = 1;
else if (a * b * c == 18)d = 1;
else if (c != 0 && a * b / c == 18)d = 1;
else if (a * (b + c) == 18)d = 1;
else if (a * (b - c) == 18)d = 1;
else if (a / b + c == 18)d = 1;
else if (a / b - c == 18)d = 1;
else if (a / b * c == 18)d = 1;
else if (c != 0 && b != 0 && a / b / c == 18)d = 1;
else if (b + c != 0 && a / (b + c) == 18)d = 1;
else if (b - c != 0 && a / (b - c) == 18)d = 1;
a = x3; b = x2; c = x1;
if (a + b + c == 18)d = 1;
else if (a + b - c == 18)d = 1;
else if (a + b * c == 18)d = 1;
else if (c != 0 && a + b / c == 18)d = 1;
else if ((a + b) * c == 18)d = 1;
else if (c != 0 && (a + b) / c == 18)d = 1;
else if (a - b + c == 18)d = 1;
else if (a - b - c == 18)d = 1;
else if (a - b * c == 18)d = 1;
else if (c != 0 && a - b / c == 18)d = 1;
else if ((a - b) * c == 18)d = 1;
else if (c != 0 && (a - b) / c == 18)d = 1;
else if (a * b + c == 18)d = 1;
else if (a * b - c == 18)d = 1;
else if (a * b * c == 18)d = 1;
else if (c != 0 && a * b / c == 18)d = 1;
else if (a * (b + c) == 18)d = 1;
else if (a * (b - c) == 18)d = 1;
else if (a / b + c == 18)d = 1;
else if (a / b - c == 18)d = 1;
else if (a / b * c == 18)d = 1;
else if (c != 0 && b != 0 && a / b / c == 18)d = 1;
else if (b + c != 0 && a / (b + c) == 18)d = 1;
else if (b - c != 0 && a / (b - c) == 18)d = 1;
if (d == 1)cout << "Yes";
else cout << "No";
cout << endl;
}
return 0;
}


#include<iostream>
#include<cmath>
using namespace std;
bool isSame(double a, double b)
{
if (abs(a - b) <= 1e-7)
{
return true;
}
else
{
return false;
}
}
bool can2(double result, int first, int second)
{
if (first + second == result
|| first - second == result
|| second - first == result
|| first * second == result
|| second != 0 && isSame(1.0 * first / second, result)
|| first != 0 && isSame(1.0 * second / first, result))
{
return true;
}
else
{
return false;
}
}
bool can31(double result, int first, int second, int third)
{
if (can2(result - first, second, third)
|| can2(first - result, second, third)
|| can2(result + first, second, third)
|| (result == 0 && first == 0 || first != 0) && can2(result*first, second, third)
|| first != 0 && can2(result / first, second, third)
|| result != 0 && first != 0 && can2(first / result, second, third))
{
return true;
}
else
{
return false;
}
}
bool can3(double result, int first, int second, int third)
{
if (can31(result, first, second, third)
|| can31(result, second, first, third)
|| can31(result, third, first, second))
{
return true;
}
else
{
return false;
}
}
int main()
{
const double result = 18;
int n;
cin >> n;
while (n--)
{
int a, b, c;
cin >> a >> b >> c;
if (can3(result, a, b, c))
{
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
}
return 0;
}


## 第六题：字符阵列

ABC
FED
GHI

#include<iostream>
#include<string>
#include<cmath>
#include<bitset>
#include<algorithm>
using namespace std;

int main()
{
int f;
cin >> f;
while (f--)
{
int m;
cin >> m;
for (int i = 1; i <= m; i++)
{
for (int p = 1; p <= m; p++)
{
if (i % 2 == 1)
{
int x = p + m*(i - 1);
char n = (x - 1) % 26 + 65;
cout << n;
}
else
{
int x = (m - p + 1) + m*(i - 1);
char n = (x - 1) % 26 + 65;
cout << n;
}
}
cout << endl;
}
}
return 0;
}