网址:https://www.nowcoder.com/acm/contest/201#question

A.签到

手速石头剪刀布

#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int a, b, c, d, e, f;
scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
printf("%d\n", min(a, e)+min(b, f)+min(c, d));
}

E.签到,贪心

#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int a[];
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for(int i = ; i < n; i++)
scanf("%d", &a[i]);
sort(a,a+n);
int ans = ;
for(int i = ; i < n; i++)
{
if(abs(a[i] - a[i-]) > m) ans++;
}
printf("%d\n", ans);
}

L.看似计算几何的最短路

题意:平面上有一条直线和n个圆,从一条直线走到另一条直线,在圆上和直线上走不消耗,其他地方消耗==路程,问最少消耗

思路:因为在圆上走不消耗,就相当于一个点,把圆抽象成点,相交或包含的圆就是一个点,相离的圆抽象成距离为(两圆圆心距离 - r1 - r2)的两个点,跑最短路

队友写的,不放代码了,耶

C.暴力枚举。。。。。。

题意:满足ax+by=c的整数x, y中,能使p2*x2+p1*x+q2*y2+q1*y取最小值的那组x, y 输出这个最小值

无言以对。。。

就当学习一波拓展欧几里得吧

拓展欧几里得,就是求关于x,y的方程 ax + by = gcd(a,b) 的所有整数解

LL exgcd(LL a,LL b,LL &x,LL &y)
{
if(a== && b==) return -;
if(b==)
{
x=, y=;
return a;
}
LL d = exgcd(b, a%b, y, x);
y -= a/b*x;
return d;
}

对于方程a * x + b * y = c 来说,如果c % gcd(a,b) != 0,即c不是gcd的整数倍,则无解。
如果c % gcd(a,b) == 0 且 c / gcd(a,b) = t,那么求出方程 a * x + b * y = gcd(a,b)的所有解x,y,将x,y乘上t,对应的x’,y’即是方程a * x + b * y = t * gcd(a,b)的解

暴力枚举所有的x……

#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
using namespace std;
LL exgcd(LL a,LL b,LL &x,LL &y)
{
if (a== && b==) return -;
if (b==)
{
x=,y=;
return a;
}
LL d=exgcd(b,a%b,y,x);
y-=a/b*x;
return d;
}
LL p1,p2,q1,q2;
LL cal(LL x, LL y)
{
return p2*x*x+p1*x+q2*y*y+q1*y;
}
int main()
{
LL a,b,c;
LL x,y;
scanf ("%lld%lld%lld%lld%lld%lld%lld",&a,&b,&c,&p1,&p2,&q1,&q2);
LL g=exgcd(a,b,x,y);
if (c%g!= || g==-)
{
printf("Kuon\n");
return ;
}
LL res = 1000000000000000000LL;
for(x = -; x <= ; x++)
{
if((c-a*x)%b) continue;
y = (c-a*x)/b;
res = min(res, cal(x, y));
}
printf("%lld\n", res);
}

国庆集训 || Wannafly Day1的更多相关文章

  1. 牛客国庆集训派对Day1.B.Attack on Titan(思路 最短路Dijkstra)

    题目链接 \(Description\) 给定\(n,m,C\)及大小为\((n+1)(m+1)\)的矩阵\(c[i][j]\).平面上有\((n+1)(m+1)\)个点,从\((0,0)\)编号到\ ...

  2. 牛客国庆集训派对Day1 L-New Game!(最短路)

    链接:https://www.nowcoder.com/acm/contest/201/L 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...

  3. 牛客国庆集训派对Day1 B. Attack on Titan

    B. Attack on Titan 链接 #include<cstdio> #include<algorithm> #include<cstring> #incl ...

  4. 牛客国庆集训派对Day1 Solution

    A    Tobaku Mokushiroku Kaiji 水. #include <bits/stdc++.h> using namespace std; ], b[]; void Ru ...

  5. 牛客国庆集训派对Day1:J:Princess Principal(栈模拟求括号匹配)

    题目描述 阿尔比恩王国(the Albion Kingdom)潜伏着一群代号“白鸽队(Team White Pigeon)”的间谍.在没有任务的时候,她们会进行各种各样的训练,比如快速判断一个文档有没 ...

  6. 国庆集训 || Wannafly Day4

    链接:https://www.nowcoder.com/acm/contest/205#question 一场题面非常 有趣 但是题目非常 不友好的比赛 QAQ L.数论之神   思维(?) 题意:求 ...

  7. 牛客国庆集训派对Day1 L New Game!(堆优化dijkstra+建图)

    链接:https://ac.nowcoder.com/acm/contest/201/L来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言2097 ...

  8. 2019牛客国庆集训派对day1 K题 双向链表练习题 splay区间翻转

    题目链接: 解法: 先建n颗平衡树,合并的时候将a中最右的结点翻转到根节点,b中最左的结点翻转到根节点,对合并后的根节点进行标记. #include <bits/stdc++.h> usi ...

  9. 2019牛客国庆集训派对day1

    C 存每个值存在的位置,枚举末尾的值,再枚举前面的值,哈希二分出最长相同的,即剩下的为不同的 D \(f_{i,j,k}\)为前i位,最后一个3因子在j,次因子在k G bitset处理有多少位置符合 ...

随机推荐

  1. 51nod1181【素数筛】

    思路: 直接就是筛出素数,然后我很撒比的从那个地方往后for找一个位置也是质数的输出: #include <bits/stdc++.h> using namespace std; type ...

  2. timewrap 算法

    何为延迟补偿?如何进行坐标差值?B客户端屏幕上A已经跑到东边了,但是收到服务器说"A正在西边往北跑",B到底该何去何从?我若干年前的一个实现版本,将简明扼要的解决这个问题: 影子跟 ...

  3. Unity3D教程:无缝地形场景切换的解决方法

    http://www.unitymanual.com/6718.html 当我们开发一个大型项目的时候-会遇到这样的问题(地形场景的切换)这个只是字面意思-并不是重场景1的100  100 100坐标 ...

  4. bzoj 2738: 矩阵乘法【整体二分+树状数组】

    脑子一抽开始写主席树,敲了一会发现不对-- 整体二分,用二维树状数组维护值为当前区间的格子个数,然后根据k的大小和当前询问的子矩阵里的值和k的大小关系来决定这个询问放在哪一部分向下递归 #includ ...

  5. 黑马Stream流学习 Stream流 函数式接口 Lambda表达式 方法引用

  6. day03 System Math

  7. jstl标签库jar包下载

  8. Image.resize()和Image.thumbnail()的区别

    Image.resize()和Image.thumbnail()的区别 根据代码和代码注释, 这两个函数都是对图片进行缩放, 两者的主要区别如下: resize()函数会返回一个Image对象, th ...

  9. C++ 自定义结构体的Priority Queue

    比较函数return true 意味着排序需要交换. #include <iostream> #include <queue> #include <vector> ...

  10. 在b站做计网实验 - 抓包/get/post

    前言 这篇博文是一个小实验,用python发送get/post请求,其中用到cookie登录bilibili网站并修改个人信息. 抓包 对HTTP应用而言,用浏览器自带的插件可以很方便做到抓包,比如c ...