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 ...
随机推荐
- iOS7时代我们用什么来追踪和识别用户?
要识别用户,首先就是要选择一个标识符,通过这个标识符来识别这个用户的设备(而不是用户),这个标识符要能够保证一个设备上返回的值是一样的,并且在其他设备上不会出现相同的值. 在iOS7之前,曾经有过很多 ...
- mate-desktop安装在其他目录时一些配置信息
1.mate-desktop安装在其他目录时一些配置信息 2.BIN目录下添加相应的mate-session_gtk2/3 3.首先配置如下环境变量 #!/bin/sh if [[ "${E ...
- sql 的实用函数(包含日期函数、截取字符串函数)
CONVERT() 函数是把日期转换为新数据类型的通用函数. CONVERT() 函数可以用不同的格式显示日期/时间数据. 语法 CONVERT(data_type(length),data_to_b ...
- Yii2.0数据库查询的一些简单的操作
User::find()->all(); 此方法返回所有数据: User::findOne($id); 此方法返回 主键 id=1 的一条数据(举个例子): User::find()->w ...
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
1.首先修改Apache的httpd.conf文件. 确认httpd.conf配置文件中加载了mod_rewrite.so 模块,加载的方法是去掉mod_rewrite.so前面的注释#号 讲http ...
- 公众平台调整SSL安全策略 不再支持SSLv2、SSLv3版本
昨天夜间,微信团队发布重要安全策略调整,将关闭掉SSLv2.SSLv3版本支持,不再支持部分使用SSLv2. SSLv3或更低版本的客户端调用.请仍在使用这些版本的开发者于11月30日前尽快修复升级. ...
- CSS控制表格(table)样式
CSS控制表格样式 /* 合并边框重叠部分 */ table{border-collapse:collapse;} /* 单元格边框 */ td{border:1px solid #A7AEB1;}
- PHP变量入门教程(2)超全局变量,总共9个
PHP 超全局变量 $GLOBALS 包含一个引用指向每个当前脚本的全局范围内有效的变量.该数组的键标为全局变量的 名称.从 PHP 3 开始存在 $GLOBALS 数组. $_SERVER 变量由 ...
- linux常用命令-文件搜索命令-find
find [目录] [选项] 文件名或者正则表达式 -name 根据文件名搜索 -iname 搜索文件名的时候忽略大小写 例:find /etc -name init find /etc -i ...
- opencv的图片的灰度处理‘
#include "stdafx.h" //实现将彩色图片转换成灰度图 int _tmain(int argc, _TCHAR* argv[]){ IplImage *image; ...