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也算赢. 现 ...
随机推荐
- lubuntu通过Smb访问Windows共享目录
lubuntu通过Smb访问Windows共享目录 如果未安装Smb,先安装: apt-get install smbclient smbfs 安装后,查看共享主机上的共享目录: CentOS/Red ...
- 如何在Eclipse中生成Native类对应的JNI的.h文件
1 致谢 感谢super_level网友 他的博客写的很清楚 给了我很多帮助 链接如下:http://blog.csdn.net/super_level/article/details/2124353 ...
- tree(poj 1741)
题意:给一颗n个节点的树,每条边上有一个距离v(v<=1000).定义d(u,v)为u到v的最小距离.给定k值,求有多少点对(u,v)使u到v的距离小于等于k. /* 照着点分治模板敲了敲,有很 ...
- 飞行路线(BZOJ 2763)
题目描述 Alice和Bob现在要乘飞机旅行,他们选择了一家相对便宜的航空公司.该航空公司一共在n个城市设有业务,设这些城市分别标记为0到n-1,一共有m种航线,每种航线连接两个城市,并且航线有一定的 ...
- SpringBoot自动配置的源码解析
首先,写源码分析真的很花时间,所以希望大家转的时候也请注明一下,Thanks♪(・ω・)ノ SpringBoot最大的好处就是对于很多框架都默认的配置,让我们开发的时候不必为了大一堆的配置文件头疼,关 ...
- Python基础教程笔记——第7章:更加抽象(类)
下面进入Python的面向对象: 对象的魔力: 多态:---可以对不同类的对象使用同样的操作 封装:---对外部隐藏对象内部的工作方式 继承:---以普通的类为基础建立专门的类对象 (1)多态: is ...
- msp430入门编程34
msp430中C语言的可移植--消除硬件差异
- 16 个常用的yum 命令
1. yum [-y] install package_name2. yum remove package_name 卸载指定软件3. ...
- hdu6110(线段树+lca)
题目 http://acm.hdu.edu.cn/showproblem.php?pid=6110 分析 注意到,若干条路径的交一定也是条路径 我们可以维护一个线段树,seg[l..r]存着第l条~第 ...
- 判断所ping主机的操作系统
根据它的值判断所ping主机的操作系统类型. TTL被称为生存期,也就是你所传输的数据在网络上经过的路由器的最大个数. 操作系统 TTLLINUX 64WIN2K/NT 128WINDOWS 系列 3 ...