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的更多相关文章

随机推荐

  1. web前端常用知识点

    1.常见的块级元素  内联元素   div -最常用的块级元素      dl - 和dt-dd 搭配使用的块级元素      form - 交互表单      h1 -h6- 大标题      hr ...

  2. 【转】[ppurl]从”皮皮书屋”下载电子书的姿势

    转:http://blog.csdn.net/hcbbt/article/details/42072545 写在前面的扯皮 为什么标题的”皮皮书屋”加上了引号,因为皮皮书屋(http://www.pp ...

  3. Eclipse直接运行算法第4版例子(重定向和读取指定路径文件)

    Eclipse直接运行算法第4版例子(重定向和读取指定路径文件)   版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://b ...

  4. 引用类型(C# 参考)

    C# 中有两种类型:引用类型和值类型. 引用类型的变量存储对其数据(对象)的引用,而值类型的变量直接包含其数据. 对于引用类型,两种变量可引用同一对象:因此,对一个变量执行的操作会影响另一个变量所引用 ...

  5. scratch3.0二次开发scratch3.0基本介绍(第一章)

    为什么要自己开发而不使用官方版本? 这个问题要看我们的做少儿编程教育的需求是怎么样的. scratch本身提供了离线版本以及官网在线平台供我们使用,这足以满足我们对于编程教学模块的需求.但是对于一些教 ...

  6. Windows10内嵌Ubuntu子系统初始化设置

    第一次启动 重启ubuntu Since Windows 10 version 1803, closing all WSL terminal windows won't kill background ...

  7. django restful 序列化

    https://www.cnblogs.com/wt7018/p/11456440.html https://www.cnblogs.com/wt7018/p/11530962.html

  8. mysql本地连接远程连接不上

    首先测试linux下的端口有没有开通 /etc/init.d/iptables status 查看3306端口没有开通 使用以下命令开通 /sbin/iptables -I INPUT -p tcp ...

  9. python接口自动化中,注册接口随机生成手机号码

    如大家所知在注册接口中,手机号参数需要的是未注册的手机号,而在测试用例中,你写入的手机号不一定是未注册的.所以这时需要对注册接口中传入的手机号做处理.下面我就分享一个课程里面学到的一个处理手机号的py ...

  10. [转载收藏]C#基础知识梳理系列十一:垃圾回收机制

    摘 要 基于.NET平台的开发语言中,最让开发人员爽的一点就是垃圾回收处理机制,在编码过程中,终于可以解放你的双手来关注更重要的事情.很多的资料中在讲到.NET中的垃圾回收机制时都说"CLR ...