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. vue项目使用v-charts的柱形图的各种样式和数据配置

    找了很多网上关于v-charts的柱形图使用,我发现我一模一样的配置就是没有效果,我原来是按需引入的, import VeHistogram from 'v-charts/lib/histogram' ...

  2. 测开大佬告诉你:如何5分钟快速创建restful风格的API接口-使用django restframework框架

    一.思考❓❔ 1.创建API接口难吗? 软件测试工程师: 只测过API接口, 从没创建过 应该需要掌握一门后端开发语言和后端开发框架吧!? 脑容量有限,想想就可怕 2.如何创建API接口呢? 使用Dj ...

  3. C#反射与特性(六):设计一个仿ASP.NETCore依赖注入Web

    目录 1,编写依赖注入框架 1.1 路由索引 1.2 依赖实例化 1.3 实例化类型.依赖注入.调用方法 2,编写控制器和参数类型 2.1 编写类型 2.2 实现控制器 3,实现低配山寨 ASP.NE ...

  4. Winform PPT切换图片效果

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. Redis系列之----Redis的过期设置及淘汰策略

    Redis的过期时间机制和内存淘汰策略    Redis的数据是存储在内存中的,而服务器的内存大小是有限制的,除非宕机,否则这些数据会一直存在,对于一些不再使用的key,也应当进行删除,否则会浪费内存 ...

  6. 手抖把Python2.7卸载了,导致了自己的yum不可用以及yum因python版本无法使用的问题

    摘要: 从标题就能看到我有多心如死灰了,简单介绍下我是如何自残的过程. ①首先因为需要部署爬虫程序,然后安装Python3. ②Python3系列和Python2系列版本不向下兼容,所以我就卸载了机器 ...

  7. laravel配置加解密

    基于安全考虑,我们php项目配置文件中密码应该是加密的,laravel中也提供了OpenSSL 的 AES-256-CBC 来进行加密 但是如果我们项目配置的是其他加密方式,且希望以最少的改动实现读取 ...

  8. crontab里的特殊符号%导致命令不能执行

    有群里的小伙伴说crontab里的任务不执行,具体是这样的 * * * * /bin/date "+%Y-%m-%d %H:%M:%S" >>/data/tmp/tes ...

  9. 如何构建可伸缩的Web应用?

    为什么要构建可伸缩的Web应用? 想象一下,你的营销活动吸引了很多用户,在某个时候,应用必须同时为成千上万的用户提供服务,这么大的并发量,服务器的负载会很大,如果设计不当,系统将无法处理. 接下来发生 ...

  10. SEVERE: Unable to process Jar entry [avassist xxxx.class]

    <bean id="sqlSessionTemplate2" class="org.mybatis.spring.SqlSessionTemplate" ...