目录

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. UVA1306 The K-League(最大流)

    题面 有 n n n 支队伍进行比赛,每支队伍需要打的比赛数目相同. 每场比赛恰好一支队伍胜,另一支败. 给出每支队伍目前胜的场数 w i w_i wi​ 和败的场数(没用),以及每两个队伍还剩下的比 ...

  2. 【java】学习路线8-cmd带命令编译包

    /*java类包(package)package XX.XX.XX;    包名命名规则:(以域名开头,都是小写)        com.remooo.xx        编译:javac -d . ...

  3. Tablesaw——Java统计、机器学习库

    资源 java二维数组处理可可视化库 https://github.com/jtablesaw/tablesaw plotly JS库的Java封装 https://github.com/jtable ...

  4. 第七十一篇:Vue组件的私有和全局注册

    好家伙, 1.组件的父子关系 我们封装三个组件,分别为left组件,right组件和App组件 在封装时: 在封装时,彼此的关系是独立的,并不存在父子关系 在使用时: 在使用时,根据彼此的嵌套关系,形 ...

  5. 第二章 Kubernetes快速入门

    一.四组基本概念 Pod/Pod控制器: Name/Namespace: Label/Label选择器: Service/Ingress. 二.Pod/Pod控制器 2.1 Pod Pod是K8S里能 ...

  6. Android开发2021.3.9日【模拟器路径】【外观字体】【简单快捷键】

    一. 1.模拟器存储路径 D:\Android\SDK\platforms(在本人的dell上) 2.使用软件 Android Studio4.2 3.注意事项 (1)修改JDK的路径为自己下载的JD ...

  7. Odoo自建应用初步总结(一)

    学习了<Odoo快速入门与实践 Python开发ERP指南>(刘金亮 2019年5月第1版 机械工业出版社)第6章自建应用入门后进行一下总结. 因为本书作者使用Odoo11,而目前最新版本 ...

  8. CentOS 7.7系统安装Redis 6.0.3

    前提操作 避免出现如下的错误 yum -y install gcc tcl yum -y install centos-release-scl yum -y install devtoolset-9- ...

  9. 解决inode满

    登陆服务器运行df -i 然后运行 for i in /*; do echo $i; find $i |wc -l|sort -nr; done 看看每个文件夹下面的数量 最后发现是/var/spoo ...

  10. 基于python的RSA解密算法

    摘要 网上有很多关于RSA的解密脚本,欧拉函数.欧几里得函数什么的,对于一个大专生的我来说,一窍不通,至此经历了三天三夜,我翻阅了RSA的加密原理,以及其底层算法,专研出了一套我自己的解密算法,尚有不 ...