目录

A

思路:这个题的话我们把负数和整数分别求出来,比较绝对值的大小,用较大的那个减去较小的那个就可以了。

#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; #define int long long signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
int n;
cin >> n;
int zheng = 0, fu = 0;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
if (x > 0)
zheng += x;
else
fu += x;
}
fu = abs(fu);
if (fu > zheng)
cout << fu - zheng << endl;
else
cout << zheng - fu << endl;
}
return 0;
}

B

思路:这个题一开始的时候想的是把全部的N放到前面,结果第二个测试点就WA了。其实这个题的正解是把全N和B换位置,但是有的N是不用动的,我们需要判断有几个N是不需要动的,要动的N的下标是从几开始。具体细节放在代码里。

#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; void solve()
{
int n;
cin >> n;
if (n == 1)
{
cout << 1 << endl;
cout << 1 << ' ' << 3 << endl;
return ;
}
int k = n - n / 2;
cout << k << endl;
int j = 1;
for (int i = (n / 2 + 1) * 3; i <= 3 * n; i += 3)
{
cout << j << ' ' << i << endl;
j += 3;
}
} int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
solve();
}
return 0;
}

C

思路:这个是个博弈的题,通过观察样例的话我们可以发现,我们想要让对手输的话,我们只需要一直把那个最小的数换给他,他只能把最小的那个数-1然后换出去,所以一直反复的话最小的那个数变成0的时候,那么那个人就输了。Alice是先手没所以只要第一个不是最小的那一个那么Alice就会赢反之Bob就会赢。如果第一个和后面的最小值相等的话还是Bob赢

#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; const int N = 1e6 + 10;
int a[N]; void solve()
{
int Min = 0x3f3f3f3f;
int n;
cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
if (i >= 2)
Min = min(a[i], Min);
}
if (a[1] > Min)
{
cout << "Alice" << endl;
}
else
{
cout << "Bob" << endl;
}
} int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
solve();
}
return 0;
}

Codeforces Round #832 (Div. 2) A~C题解的更多相关文章

  1. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  2. Codeforces Round #198 (Div. 2)A,B题解

    Codeforces Round #198 (Div. 2) 昨天看到奋斗群的群赛,好奇的去做了一下, 大概花了3个小时Ak,我大概可以退役了吧 那下面来稍微总结一下 A. The Wall Iahu ...

  3. Codeforces Round #672 (Div. 2) A - C1题解

    [Codeforces Round #672 (Div. 2) A - C1 ] 题目链接# A. Cubes Sorting 思路: " If Wheatley needs more th ...

  4. Codeforces Round #614 (Div. 2) A-E简要题解

    链接:https://codeforces.com/contest/1293 A. ConneR and the A.R.C. Markland-N 题意:略 思路:上下枚举1000次扫一遍,比较一下 ...

  5. Codeforces Round #610 (Div. 2) A-E简要题解

    contest链接: https://codeforces.com/contest/1282 A. Temporarily unavailable 题意: 给一个区间L,R通有网络,有个点x,在x+r ...

  6. Codeforces Round #611 (Div. 3) A-F简要题解

    contest链接:https://codeforces.com/contest/1283 A. Minutes Before the New Year 题意:给一个当前时间,输出离第二天差多少分钟 ...

  7. Codeforces Round #499 (Div. 2) D. Rocket题解

    题目: http://codeforces.com/contest/1011/problem/D This is an interactive problem. Natasha is going to ...

  8. Codeforces Round #499 (Div. 2) C Fly题解

    题目 http://codeforces.com/contest/1011/problem/C Natasha is going to fly on a rocket to Mars and retu ...

  9. Codeforces Round #198 (Div. 2)C,D题解

    接着是C,D的题解 C. Tourist Problem Iahub is a big fan of tourists. He wants to become a tourist himself, s ...

随机推荐

  1. HDU6623 Minimal Power of Prime (简单数论)

    题面 T ≤ 50   000 T\leq50\,000 T≤50000 组数据: 输入一个数 N N N ( 2 ≤ N ≤ 1 0 18 2\leq N\leq 10^{18} 2≤N≤1018) ...

  2. 使用man手册查看内核函数

    1.为避免man的一些功能缺失,先装好manpages-dev sudo apt-get install manpages-dev 2.安装mandocs的依赖包xmlto sudo apt-get ...

  3. 插入排序C语言版本

    算法思路:        每趟将一个待排序的元素作为关键字,按照其关键字值的大小插入到已经排好的部分的适当位置上,直到插入完成.        数组中待排序的关键字前面的数据为已经排序的数据,关键字插 ...

  4. 注解@PostConstruct分析

    作用 1.注解@PostConstruct可以添加在类的方法上面,如果这个类被IOC容器托管,那么在对Bean进行初始化前的时候会调用被这个注解修饰的方法 被定义在哪里? 1.被定义在了CommonA ...

  5. .NET6 使用 AutoMapper (解析)

    一.Net 6环境下的.net core项目里如何使用AutoMapper实现依赖注入. 注: AutoMapper 是一个对象-对象映射器,可以将一个对象映射到另一个对象. 第一步,在Nuget引入 ...

  6. postman7种断言的使用

    导航:1.postman断言介绍2.状态码断言3.响应正文断言-包含4.响应正文断言-json字段5.响应头断言6.响应时间断言7.环境变量的断言 - - - - - - - - - 分割线 - - ...

  7. LeNet-论文阅读

    概述 Yann LeCun, Leon Bottou, Yoshua Bengio, and Patrick Haffner的论文<Gradient-Based Learning Applied ...

  8. tensorflow-gpu版本安装及深度神经网络训练与cpu版本对比

    tensorflow1.0和tensorflow2.0的区别主要是1.0用的静态图 一般情况1.0已经足够,但是如果要进行深度神经网络的训练,当然还是tensorflow2.*-gpu比较快啦. 其中 ...

  9. 基于QT和C++实现的翻金币游戏

    基于QT和C++的翻金币游戏 声明: QT翻金币项目可以说是每个新学QT的同学都会去写的一个项目,网上的源码也很多,我也是最近刚开始学QT,所以也参考了很多前辈的代码自己重新敲了一遍代码. 游戏介绍: ...

  10. MySQL安装卸载、idea中Database的使用、常用的sql语句

    MySQL安装卸载 MySQL安装 在下面的资源链接中下载MySQL软件压缩包(绿色版),这个版本是MySQL5.7.29的,本教程也只适用于这个绿色版的,如果下载的是安装包那就可能有些地方不一样了, ...