D. Shichikuji and Power Grid</centerD.> Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows: There are…
链接: https://codeforces.com/contest/1245/problem/D 题意: Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows: There are n new cities located in Prefecture X. Cities are numbered from 1 to n. City i is locate…
题目链接:https://codeforces.com/contest/1245/problem/D 题目大意: 平面上有n座城市,第i座城市的坐标是 \(x[i], y[i]\) , 你现在要给n城市供电,对于第i座城市,你可以选择两种方式给其供电: 建造一个发电站供电,这需要花费 \(c[i]\) : 连一条连向城市j的电缆,这需要花费 \((|x[i]-x[j]|+|y[i]-y[j]|) \times (k[i]+k[j])\) . 现在告诉你n以及 \(x[i], y[i], c[i]…
#include<bits/stdc++.h> using namespace std ; int n; struct City { int id; long long x,y; //坐标 long long cc,kk; //自建的花费,连线的花费 bool self;//是否建站 int fa;//连线的站 bool operator < (const City & a)const { return cc<a.cc; } } c[]; int main() { scan…
[Codeforces 1245D] Shichikuji and Power Grid (最小生成树) 题面 有n个城市,坐标为\((x_i,y_i)\),还有两个系数\(c_i,k_i\).在每个城市建立发电站需要费用\(c_i\).如果不建立发电站,要让城市通电,就需要与有发电站的城市连通.i与j之间连一条无向的边的费用是\((k_i+k_j)\)*两个城市之间的曼哈顿距离.求让每个城市都通电的最小费用,并输出任意一个方案. 分析 把选每个点的代价转成虚拟原点到这个点的边,这个套路很常见,…
A - Good ol' Numbers Coloring 题意:有无穷个格子,给定 \(a,b\) ,按以下规则染色: \(0\) 号格子白色:当 \(i\) 为正整数, \(i\) 号格子当 \(i\geq a\) 且 \(i-a\) 是白色格子时涂白色:当 \(i\) 为正整数, \(i\) 号格子当 \(i\geq b\) 且 \(i-b\) 是白色格子时涂白色:仍不是白色的涂黑色,问黑色格子是否有无穷个. 题解:好像做过很多次了,遍历所有的整数的充要条件是这些拿来线性组合的步长的gcd…
链接: https://codeforces.com/contest/1245/problem/C 题意: Constanze is the smartest girl in her village but she has bad eyesight. One day, she was able to invent an incredible machine! When you pronounce letters, the machine will inscribe them onto a pie…
链接: https://codeforces.com/contest/1245/problem/B 题意: Let n be a positive integer. Let a,b,c be nonnegative integers such that a+b+c=n. Alice and Bob are gonna play rock-paper-scissors n times. Alice knows the sequences of hands that Bob will play. H…
链接: https://codeforces.com/contest/1245/problem/A 题意: Consider the set of all nonnegative integers: 0,1,2,-. Given two integers a and b (1≤a,b≤104). We paint all the numbers in increasing number first we paint 0, then we paint 1, then 2 and so on. Ea…
题:https://codeforces.com/contest/1245/problem/F 分析:转化为:求区间内满足a&b==0的对数(解释见代码) ///求满足a&b==0在区间[l,r]的对数 ///推导:区间[2l,2r]可由[l,r]乘3倍得来 ///原因:*2我们可以看成事左移1位,那么这个位置上,对于俩个数来说 /////////可以取0,1 或1,0或0,0才依然满足 a&b==0这个题目条件 /////////这个公式可以用递归推导回溯计算, ////////…