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. 1070 结绳 (25 分)C语言

    给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下图所示套接在一起.这样得到的绳子又被当成是另一段绳子,可以再次对折去跟另一段绳子串连.每次串连后,原来两段绳子的长度 ...

  2. 01_垂直居中body中的应用

    1: 应用场景 在body中书写一个代码块, 使其相对于body垂直居中 <!DOCTYPE html> <html lang="en"> <head ...

  3. day2(使用list和tuple)

    list list是一种有序的集合 >>>aaa = ['abc','bob','tracy'] >>>aaa ['abc','bob','tracy'] len( ...

  4. spring boot事务管理

    spring boot集成事务十分的简单,只需要在启动类上面增加@EnableTransactionManagement注解,然后在需要实现事务的方法上添加@Transactional注解就可以了.下 ...

  5. Windows安装EMQ服务器(mqtt)

    先去EMQ官网下载安装包 https://www.emqx.io/downloads#broker 注意:此处一定不能下错成企业版的,不然EMQ会由于缺少企业license无法启动服务 解压到任意路径 ...

  6. Have Fun with Numbers

    Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, wit ...

  7. 【一起学源码-微服务】Hystrix 源码一:Hystrix基础原理与Demo搭建

    说明 原创不易,如若转载 请标明来源! 欢迎关注本人微信公众号:壹枝花算不算浪漫 更多内容也可查看本人博客:一枝花算不算浪漫 前言 前情回顾 上一个系列文章讲解了Feign的源码,主要是Feign动态 ...

  8. 6、使用基元类型而不要使用 FCL 类型

    基元类型: int string object uint long ulong 等 ; FCL (Framework Class Library ) System.Int32 等. 一些定义在一些语言 ...

  9. Go 每日一库之 cobra

    简介 cobra是一个命令行程序库,可以用来编写命令行程序.同时,它也提供了一个脚手架, 用于生成基于 cobra 的应用程序框架.非常多知名的开源项目使用了 cobra 库构建命令行,如Kubern ...

  10. sql if else 语句

    IF ELSE 语句IF ELSE 是最基本的编程语句结构之一几乎每一种编程语言都支持这种结构而它在用于对从数据库返回的数据进行检查是非常有用的TRANSACT-SQL 使用IF ELSE的例子如下语 ...