Codeforces_851
A.分三种情况。
#include<bits/stdc++.h>
using namespace std; int n,k,t; int main()
{
ios::sync_with_stdio();
cin >> n >> k >> t;
if(t <= k) cout << t << endl;
else if(t <= n) cout << k << endl;
else cout << k-(t-n) << endl;
}
B.a,b,c不共线且ab == bc则Yes。
#include<bits/stdc++.h>
using namespace std; long long ax,ay,bx,by,cx,cy; int main()
{
ios::sync_with_stdio();
cin >> ax >> ay >> bx >> by >> cx >> cy;
if((ay-by)*(bx-cx) == (by-cy)*(ax-bx) || (ay-by)*(ay-by)+(ax-bx)*(ax-bx) != (by-cy)*(by-cy)+(bx-cx)*(bx-cx)) cout << "No" << endl;
else cout << "Yes" << endl;
return ;
}
C.暴力剪枝一下。
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std; int n,ok[];
struct xx
{
double a1,a2,a3,a4,a5;
}a[]; double f(int i,int j,int k)
{
double t1 = a[k].a1-a[i].a1,t2 = a[k].a2-a[i].a2,t3 = a[k].a3-a[i].a3,t4 = a[k].a4-a[i].a4,t5 = a[k].a5-a[i].a5;
double x1 = a[j].a1-a[i].a1,x2 = a[j].a2-a[i].a2,x3 = a[j].a3-a[i].a3,x4 = a[j].a4-a[i].a4,x5 = a[j].a5-a[i].a5;
return acos((t1*x1+t2*x2+t3*x3+t4*x4+t5*x5)/sqrt(t1*t1+t2*t2+t3*t3+t4*t4+t5*t5)/sqrt(x1*x1+x2*x2+x3*x3+x4*x4+x5*x5));
} int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++)
{
cin >> a[i].a1 >> a[i].a2 >> a[i].a3 >> a[i].a4 >> a[i].a5;
ok[i] = ;
}
for(int i = ;i <= n;i++)
{
if(!ok[i]) continue;
for(int j = ;j <= n;j++)
{
if(i == j) continue;
if(!ok[i]) break;
for(int k = ;k <= n;k++)
{
if(k == i) continue;
if(k == j) continue;
if(!ok[i]) break;
double t1 = f(i,k,j);
double t2 = f(k,i,j);
double t3 = f(j,k,i);
if(t1/PI* < -1e-) ok[i] = ;
if(t2/PI* < -1e-) ok[k] = ;
if(t3/PI* < -1e-) ok[j] = ;
}
}
}
int cnt = ;
for(int i = ;i <= n;i++)
{
if(ok[i]) cnt++;
}
cout << cnt << endl;
for(int i = ;i <= n;i++)
{
if(ok[i]) cout << i << endl;
}
return ;
}
D.暴力每个gcd的值,统计前缀个数和前缀和,优化一下。
#include<bits/stdc++.h>
using namespace std; int n,cnt[] = {},vis[] = {};
long long x,y,sum[] = {}; int main()
{
ios::sync_with_stdio();
cin >> n >> x >> y;
for(int i = ;i <= n;i++)
{
int x;
cin >> x;
cnt[x]++;
sum[x] += x;
}
for(int i = ;i <= ;i++)
{
cnt[i] += cnt[i-];
sum[i] += sum[i-];
}
long long ans = 1e18;
for(int i = ;i <= ;i++)
{
if(vis[i]) continue;
long long xx = ;
for(int j = i;j <= +i;j += i)
{
vis[j] = ;
int t = max(j-(int)(x/y),j-i+);
xx += ((long long)(cnt[j]-cnt[t-])*j-(sum[j]-sum[t-]))*y;
xx += (cnt[t-]-cnt[j-i])*x;
}
ans = min(ans,xx);
}
cout << ans << endl;
return ;
}
Codeforces_851的更多相关文章
随机推荐
- FTP服务器红帽5.4搭建图文教程!!!
FTP服务器搭建 服务器的环境 红帽5.4 vm15 挂载光盘 mount mount -t iso9660 设备目录 /mnt 表示挂载 软件包安装 FTP服务器安装包命令: rpm -ivh /m ...
- 侠说java8-行为参数化(开山篇)
啥是行为参数化 行为参数化的本质是不执行复杂的代码块,让逻辑清晰可用. 相信使用过js的你肯定知道,js是可以传递函数的,而在 java中也有类似的特性,那就是匿名函数. 理解:行为参数化是一种方法, ...
- 12款好用的Visual Studio插件,最后一款良心推荐
目录 01 CodeMaid 02 Markdown Editor 03 ReSharper 04 GitHub Extension for Visual Studio 05 ZenCoding 06 ...
- [开源] SEPP——研发协作一站式管理平台
演示地址 http://www.seqcer.com/ 仅对chrome浏览器做了完全适配,其他chromium核心浏览器或者firefox.safari也能使用,但是不推荐 仓库地址: 前端:htt ...
- Magicodes.IE编写多框架版本支持和执行单元测试
背景 很多情况下,我们编写了一些工具库之后,往往在某些框架版本中会出现一些问题,比如本人最近写的一个导入导出的工具库Magicodes.IE(GitHub:https://github.com/xin ...
- Spring Boot中利用递归算法查询到所有下级用户,并手动进行分页
Spring Boot中利用递归算法查询到所有下级用户,并手动进行分页 前提:语言用的是kotlin(和Java一样,但更简洁),写下这篇文章用来记录编程过程中遇到的一些难点 1.功能需求 前端用户A ...
- 基于JGraphT实现的路径探寻
基于JGraphT实现的路径探寻 业务中提出基于内存,探寻的两点间的有向以及无向路径,多点间的最小子图等需求,以下记录使用JGraphT的实现过程. GraphT是免费的Java类库,提供数学图论对象 ...
- es snapshot备份到hdfs及从hdfs恢复snapshot
snapshot可以将es整个集群,具体索引数据备份到磁盘,hdfs等.需要时,可以从磁盘,hdfs恢复数据到es. 具体参考: https://elasticsearch.cn/article/61 ...
- arthas 使用指导
arthas 阿尔萨斯 这种命令行的东西首先得知道 如何使用帮助,帮助文档最先开始用的,应该是可以在网上找到的官方文档 文档一:https://alibaba.github.io/arthas/ind ...
- Python中url标签使用详解
url标签: 1.在模板中,我们经常要使用一些url,实现页面之间的跳转,比如某个a标签中需要定义href属性.当然如果通过硬编码的方式直接将这个url固定在里面也是可以的,但是这样的话,对于以后进行 ...