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. 使用Theia——添加语言支持

    上一篇:使用Theia——创建插件 Theia——添加语言支持 Theia中TextMate的支持 使用TextMate语法可以为大部分源文件提供精准的着色修饰,虽然这只是在语法级别上(没有语言本身的 ...

  2. kettle高级教程-自动同步

    KETTLE4个工作中有用的复杂实例--2.两表数据比较,比较后自动同步(部门.单位数据同步) 二.两表数据比较核对,核对后自动同步至目标数据表 目标:比较t_bm表的数据和t_bm_target表的 ...

  3. axios封装的拦截器的应用

    axios拦截器   页面发送http请求,很多情况我们要对请求和其响应进行特定的处理:如果请求数非常多,单独对每一个请求进行处理会变得非常麻烦,程序的优雅性也会大打折扣.好在强大的axios为开发者 ...

  4. 【tf.keras】Linux 非 root 用户安装 CUDA 和 cuDNN

    TensorFlow 2.0 for Linux 使用时报错:(cuDNN 版本低了) E tensorflow/stream_executor/cuda/cuda_dnn.cc:319] Loade ...

  5. 速石科技携HPC混合云平台亮相AWS技术峰会2019上海站

    2019年6月20日,全球云技术盛会——AWS技术峰会2019(上海站)在上海世博中心举行.作为AWS的技术合作伙伴,速石科技携旗下基于混合云的一站式高性能计算(HPC)平台首次公开亮相. 速石科技向 ...

  6. SpringCloud-Hystrix原理

    Hystrix官网的原理介绍以及使用介绍非常详细,非常建议看一遍,地址见参考文档部分. 一 Hystrix原理 1 Hystrix能做什么 通过hystrix可以解决雪崩效应问题,它提供了资源隔离.降 ...

  7. Friday the Thirteenth 黑色星期五 USACO 模拟 超级简单做法

    1003: 1.1.3 Friday the Thirteenth 黑色星期五 时间限制: 1 Sec  内存限制: 128 MB提交: 8  解决: 8[提交] [状态] [讨论版] [命题人:外部 ...

  8. DP-直线分割递推

    在 DP  里有一类是直线分割平面的问题 , 也是属于递推 类的 . 一 . 直线分割平面的问题 先考虑第一个小问题 : n 条直线最多可以将平面分割成几部分 ? 想想 最优的分割方法是怎样的呢 ? ...

  9. dfs - 走过的标记取消

    在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C. ...

  10. Oracle RAC服务器重启故障排查

    Oracle Real Application Clusters(Oracle RAC),相对于Oracle单实例来说部署安装和维护都增加了难度,尤其在日常的维护和故障处理过程中,各种日志的查看更加重 ...