读书人

Codeforces Round #201 (Div. 二) ABC

发布时间: 2013-09-24 10:59:52 作者: rapoo

Codeforces Round #201 (Div. 2) ABC 水题3道

这场的题目也很水,但是我竟然在第二题浪费了5次提交,罚时严重啊T T

果然还是太水了,姑且写个题解。。。

A - Difference Row

手速题,我还蛋疼把最大值和最小值提取出来重新排序了。。。

其实只要全部排序,让最大和最小位置调换下就行了。

复杂度为sort的O(nlogn)

代码:

/**  Author:      illuz <iilluzen[at]gmail.com>*  Blog:        http://blog.csdn.net/hcbbt*  File:        c.cpp*  Create Date: 2013-09-21 00:41:09*  Descripton:  gcd */#include <cstdio>#include <iostream>#include <algorithm>using namespace std;#define rep(i, n) for (int i = 0; i < (n); i++)typedef long long LL;LL g, t;LL gcd(LL a, LL b) {if(b == 0)return a;return gcd(b, a % b);}int main() {int n;LL Max = 0;cin >> n;rep(i, n) {cin >> t;if (i)g = gcd(g, t);elseg = t;Max = max(Max, t);}LL cnt = Max / g - n;if (cnt % 2 == 0) printf("Bob\n");else printf("Alice\n");return 0;}


读书人网 >编程

热点推荐