A
单纯简单博弈
刚刚看到这个题的时候我以为看到了原题(原因就是我cf做过一道几乎一模一样的题但是不同一样就是我发现cf的那道题题目不可以减一而这道题可以
单纯判断奇偶
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
int n;
int main()
{
cin >> n;
if (n % 2 == 1) cout << "Bob" << endl;
else {
cout << "Alice" << endl;
}
return 0;
}
B
这道题打表就ok没有什么大的思考量
但是简简单单的打卡我卡了一个小时 原因就是我以为是的小聪明
当k = 2的时候一定要注意i最好要出现i>4要不然就可能不仅仅是两种情况了。。这个点我被坑死了wa了两回
#include <algorithm>
#include <iostream>
using namespace std;
int k,n;
int main()
{
cin >> k >> n;
if (k == 1)
{
for (int i = 1; i <= 10; i ++ )
{
for (int j = 1; j <= 10; j ++ )
{
cout << i * 10 << j * 10 << i * 10 + j * 10 << endl;
n --;
if (n == 0) break;
}
if (n == 0) break;
}
}
else if (k == 0)
{
for (int i = 1; i <= 10; i ++)
{
for (int j = 1; j <= 10; j ++ )
{
cout << i << j << 0 << i + j << endl;
n --;
if (n == 0) break;
}
if (n == 0) break;
}
}
else {
for (int i = 1; i <= 9; i ++ )
{
long long r = i;
for (int j = 1; j <= 10; j ++ )
{
long long l = r;
for (int k = j + 1; k <= 10; k ++ )
{
l = l * 10 + i;
cout << l << r << l + r << endl;
n --;
if (n == 0) break;
}
r = r * 10 + i;
if (n == 0) break;
}
if (n == 0) break;
}
}
return 0;
}
C
#include <algorithm>
#include <iostream>
#include <cstring>
#define xx first
#define yy second
#define ll long long
#define L(i, j, k) for (int i = j; i <= k; i ++)
#define R(i, j, k) for (int i = j; i >= k; i --)
using namespace std;
const int N = 2e5 + 10;
ll a[N], q, b, n,f[N], g[N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++ ) cin >> a[i];
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i ++ )
{
ll cnt = (a[i + 1] - f[i - 1] - 1) / a[i];//取a[i]到a[i + 1]之间最多的纸币张数
f[i] = f[i - 1] + cnt * a[i];//累计需要多少钱
g[i] = g[i - 1] + cnt;//累计最多的纸币张数
}
cin >> q;
while (q -- )
{
cin >> b;
int p = upper_bound(a + 1, a + n + 1, b) - a - 1;//二分比b小的第最大点的位置
cout << f[p - 1] + (b - f[p - 1]) / a[p] * a[p] << " ";
cout << g[p - 1] + (b - f[p - 1]) / a[p] << endl;
}
return 0;
}