Codeforces Round #365 (Div. 2)
水。。随便统计一下就A了
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,-1,sizeof(x))
int main()
{
,cnt2 = ;
scanf("%d",&n);
; i < n; i++)
{
scanf("%d%d",&x,&y);
if(x > y)
cnt1++;
else if(x < y)
cnt2++;
}
if(cnt1 > cnt2)
printf("Mishka\n");
else if(cnt1 < cnt2)
printf("Chris\n");
else
printf("Friendship is magic!^^\n");
;
}
题目大意:有n个城市,1-2-3-...-n-1连接,然后有k个首都,每个首都和每个城市都有一条路相连。但是,每两座城市直接最多只有一条路。每条路的权值,等于两个城市的魅力值乘积。问你所有路的权值之和是多少。
思路比较重要。这种类似的题型做过两三次了吧。
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,-1,sizeof(x))
+ ;
int c[maxn], vis[maxn];
int main()
{
mem0(vis);
int n,k;
scanf("%d%d",&n,&k);
LL sum = , ans = ;
; i <= n; i++)
scanf("%d",&c[i]), sum += c[i];
; i < k; i++)
{
int x;
scanf("%d",&x);
sum -= (LL)c[x];
ans += (LL)c[x] * sum;
vis[x] = ;
}
c[n+] = c[], vis[n+] = vis[];
; i <= n; i++)
{
])
ans += (LL)c[i] * c[i+];
}
printf("%lld\n",ans);
;
}
这道题毫无头绪。。。
Codeforces Round #365 (Div. 2)的更多相关文章
- Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...
- Mishka and Divisors[CodeForces Round #365 Div.2]
http://codeforces.com/contest/703/problem/E 题意:给定一个最多个数的序列,从中选出最少个数的数字,使得他们的乘积是k的倍数,若有多种选择方式,输出选出数字和 ...
- Codeforces Round #365 (Div. 2)-D Mishka and Interesting sum(树状数组)
题目链接:http://codeforces.com/contest/703/problem/D 思路:看了神犇的代码写的... 偶数个相同的数异或结果为0,所以区间ans[l , r]=区间[l , ...
- Codeforces Round #365 (Div. 2) A 水
A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum 离线+线段树
题目链接: http://codeforces.com/contest/703/problem/D D. Mishka and Interesting sum time limit per test ...
- Codeforces Round #365 (Div. 2) D. Mishka and Interesting sum (离线树状数组+前缀xor)
题目链接:http://codeforces.com/contest/703/problem/D 给你n个数,m次查询,每次查询问你l到r之间出现偶数次的数字xor和是多少. 我们可以先预处理前缀和X ...
- Codeforces Round #365 (Div. 2) E - Mishka and Divisors(转化成01-背包)
http://codeforces.com/contest/703/problem/E 题意: 给出n个数和一个k,计算出至少要多少个数相乘才是k的倍数. 思路:这道题目参考了杭电大神的代码http: ...
- Codeforces Round #365 (Div. 2) D - Mishka and Interesting sum(离线树状数组)
http://codeforces.com/contest/703/problem/D 题意: 给出一行数,有m次查询,每次查询输出区间内出现次数为偶数次的数字的异或和. 思路: 这儿利用一下异或和的 ...
- Codeforces Round #365 (Div. 2) B - Mishka and trip
http://codeforces.com/contest/703/problem/B 题意: 每个点都有一个值,每条边的权值为这两个点相乘.1~n成环.现在有k个城市,城市与其他所有点都相连,计算出 ...
- Codeforces Round #365 (Div. 2) A
Description Mishka is a little polar bear. As known, little bears loves spending their free time pla ...
随机推荐
- Alpha阶段第十次Scrum Meeting
情况简述 Alpha阶段第十次Scrum Meeting 敏捷开发起始时间 2016/11/3 00:00 敏捷开发终止时间 2016/11/4 00:00 会议基本内容摘要 详细定义了API接口,汇 ...
- python标准模块(三)
本文会涉及到的模块: subprocess logging 1. subprocess 可以执行shell命令的相关模块和函数有: os.system os.spawn os.popen --废弃 p ...
- Arcgis 10.1安装
来源http://download.csdn.net/detail/l_j_kin/7310665#comment 测试有效,存着备用,转过来不自己写了 安装desktop 打开“注册机”,功能选择a ...
- Property和attribute的区别[转]
Attribute和Property都可以翻译成“属性”,有的地方用Attribute表示“属性”,有的地方又在用Property,初 学者常常在这两个单词间“迷失”,甚至认为二者没有区别,是一样的. ...
- C# 使用Silverlight toolkit Chart
一.基础介绍 Silverlight ToolKit是微软发布的基于Microsoft-Public License(MS-PL)许可协议的控件集.MS-PL许可协议允许商业或非商业的发布,所以我们可 ...
- PHP判断文件或者目录是否可写
在PHP中,可用is_writable()函数来判断一个 文件/目录 是否可写,详情如下: 参考 is_writable (PHP 4, PHP 5) is_writable — 判断给定的文件名是否 ...
- Alpha版本冲刺总结——曙光初现
No Bug 031402401鲍亮 031402402曹鑫杰 031402403常松 031402412林淋 031402418汪培侨 031402426许秋鑫 项目预期计划 界面设计 androi ...
- ReactiveCocoa源码拆分解析(六)
(整个关于ReactiveCocoa的代码工程可以在https://github.com/qianhongqiang/QHQReactive下载) RAC为了实现优雅的信号绑定,可谓使尽浑身解数,不仅 ...
- MVC项目使用easyui的filebox控件上传文件
开发环境:WIN10+IE11,浏览器请使用IE10或以上版本 开发技术框架MVC4+JQuery Easyui+knockoutjs 效果为弹出小窗体,如下图 1.前端cshtml文件代码(只包含文 ...
- Wampserver主机服务配置方法
一.更改根目录 1.左键”www目录”路径更改Wampserver安装好后,“www目录”默认为X:\wamp\www,也就是wampserver安装目录下的www文件夹.实际使用中,默认设置往往不 ...