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 ...
随机推荐
- Codeforces Round #342 (Div. 2) C. K-special Tables(想法题)
传送门 Description People do many crazy things to stand out in a crowd. Some of them dance, some learn ...
- myeclipse给项目改了名字,但部署tomcat的项目名还是原来的
如标题所示: 在myeclipse中按F2改了项目名称,之前在tomcat中部署的名称是另一个,再次重新部署,永远是上一个的旧名称 解决办法: 项目点右键-properties-左上角搜索框输入web ...
- win7下装ubuntu14.04双系统
一.给ubuntu准备安装空间 计算机--右键--管理-磁盘管理--选择一个空余空间较多的磁盘--右键--压缩卷--压缩大概60G空间(接下来ubuntu就会装到这60G里面) 二.制作启动u盘 ...
- 11月6日下午PHP分页查询(查询结果也显示为分页)
1.先把数据库里所有的数据分页显示在页面,并在显示数据的表格上方加上查询表单. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit ...
- [Unity3D]粒子系统学习笔记
粒子阴影的处理 通过Material填充粒子系统的render后,默认是显示阴影的: 可以通过设置来调整: 调整后的效果, 每个粒子就没有阴影了 增加粒子效果 设置为合成的材质,效果显示加倍: 添加子 ...
- ThinkPhp 验证码不显示图片
验证码不显示原因分析: 1.先确保是否开启了 gd库 2.页面是否存在bom头 3.导入的ORG.Util.Image是否存在 4.入口文件中是否有define('APP_DEBUG', TRUE); ...
- 《大道至简》第一章读后感--JAVA语言伪代码形式
import.java.大道至简.*; //一·愚公移山 import.java.愚公移山.*; public class YuGongYiShan { //原始需求:惩山北之塞,出入之迂 //项目沟 ...
- JS中数组Array的用法{转载}
js数组元素的添加和删除一直比较迷惑,今天终于找到详细说明的资料了,先给个我测试的代码^-^var arr = new Array();arr[0] = "aaa";arr[1] ...
- java基础知识(一)数据类型(上)
java的数据类型 由上图,java的数据类型分为基本数据类型.引用数据类型两大类. 1.基本数据类型 与c不同,java的各种数据类型占有固定长度的内存,与具体的软硬件平台无关:另外,每种数据类型都 ...
- JBOSS 5 session时间配置
C:\jboss-5.1.0.GA\server\default\deployers\jbossweb.deployer web.xml <session-config> < ...