codeforces round#432 div2
C:这道题没做出来...写了个类似极角排序的东西被卡掉了...事实上暴力就行了,因为如果在二维平面内那么最多只能有4个点,因为每个象限只能有一个点,然后这里拓展一下就是最多只能有2*k个点,k是维数,所以大概枚举2*k=10就跳出循环了
#include<bits/stdc++.h>
using namespace std;
const int N = ;
const double pi = acos(-);
struct points {
double a[];
points friend operator - (points a, points b)
{
points ret;
for(int i = ; i < ; ++i) ret.a[i] = a.a[i] -b.a[i];
return ret;
}
} p[N];
int n, ans;
int mark[N];
double calc(points a, points b)
{
double ret = ;
for(int i = ; i < ; ++i) ret += a.a[i] * b.a[i];
return ret;
}
int main()
{
scanf("%d", &n);
for(int i = ; i <= n; ++i)
for(int j = ; j < ; ++j)
scanf("%lf", &p[i].a[j]);
ans = n;
for(int i = ; i <= n; ++i)
for(int j = ; j <= n && !mark[i]; ++j) if(i != j)
for(int k = ; k <= n; ++k) if(i != j && k != j)
{
points a = p[j] - p[i], b = p[k] - p[i];
if(calc(a, b) > )
{
mark[i] = , --ans;
break;
}
}
cout << ans << endl;
for(int i = ; i <= n; ++i) if(!mark[i]) cout << i << endl;
return ;
}
D:暴力枚举GCD,然后贪心计算一下,具体看程序,gcd的题见到过有几种方法,1.gcd个数不超过log个,2.修改可以差分,3.类似莫比乌斯反演的容斥,4.像这样暴力枚举。大概也逃不出这几种方法了吧
#include<bits/stdc++.h>
using namespace std;
const int N = ;
int n, x, y, m;
int mark[N], a[N];
long long s[N], c[N];
long long ans = 1ll << ;
int main()
{
cin >> n >> x >> y;
for(int i = ; i <= n; ++i) scanf("%d", &a[i]), ++ c[a[i]], s[a[i]] += a[i], m = max(m, a[i]);
for(int i = ; i <= ; ++i) c[i] += c[i - ], s[i] += s[i - ];
for(int i = ; i <= ; ++i)
{
long long sum = ;
for(int j = i; j <= + i; j += i)
{
int p = max(j - i + , j - (x / y));
sum += ((c[j] - c[p - ]) * (long long)j - s[j] + s[p - ]) * (long long)y;
sum += (c[p - ] - c[j - i]) * (long long)x;
}
// printf("i = %d sum = %lld\n", i, sum);
ans = min(ans, sum);
}
cout << ans << endl;
return ;
}
codeforces round#432 div2的更多相关文章
- Codeforces Round #539 div2
Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...
- 【前行】◇第3站◇ Codeforces Round #512 Div2
[第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...
- Codeforces Round#320 Div2 解题报告
Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...
- Codeforces Round #564(div2)
Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- Codeforces Round #626 Div2 D,E
比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...
- CodeForces Round 192 Div2
This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- Codeforces Round #360 div2
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现 ...
随机推荐
- 洛谷P3973 - [TJOI2015]线性代数
Portal Description 给定一个\(n\times n\)的矩阵\(B\)和一个\(1×n\)的矩阵\(C\).求出一个\(1×n\)的01矩阵\(A\),使得\(D=(A×B-C)×A ...
- 【最小费用最大流】N. April Fools' Problem (medium)
http://codeforces.com/contest/802/problem/N [题解] 方法一: #include<bits/stdc++.h> using namespace ...
- PHP统计目录中文件个数和文件大小
<meta charset="utf-8"><?php $dirn = 0; //目录数 $filen = 0; //文件数 //用来统计一个目录下的文件和目录的 ...
- msp430入门编程47
msp430中C语言的人机交互--菜单退出 msp430入门编程 msp430入门学习
- 原 ELK+Filebeat集中式日志解决方案(centos7)
https://blog.csdn.net/bittersweet0324/article/details/78503961
- 247. Segment Tree Query II
最后更新 二刷 09-Jna-2017 利用线段树进行区间查找,重点还是如何判断每一层的覆盖区间,和覆盖去见与当前NODE值域的关系. public class Solution { public i ...
- Random Forest 与 GBDT 的异同
曾经在看用RF和GBDT的时候,以为是非常相似的两个算法,都是属于集成算法,可是细致研究之后,发现他们根本全然不同. 以下总结基本的一些不同点 Random Forest: bagging (你懂得. ...
- Python 离线等价类
离线等价类的概念见离线等价类 最近在清洗数据的时候涉及到要将相似度比较高的文件夹合并,特征比对得到是1:1的对,比如: (a,b),(c,d),(a,c)...,那么合并的时候就涉及到将这些等价的对合 ...
- TCP协议,UDP协议
帅爆太阳的男人 1,TCP协议 回环地址:127.0.0.1(所有电脑都这一个默认回环地址)每个计算机都有这么一个本机地址只能被本机识别,不会被其他机器识别(因为你用这个地址传内容他就传不出去) TC ...
- Hibernate 之 Why?
本文主要是从一个宏观的角度来认识Hibernate,对为什么用Hibernate进行一些说明,通过指导并了解Hibernate的特性及其优缺点可以让我们在以后的项目中根据具体的情况进行选择. Hibe ...