网址: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. Fitnesse的一个简单实例

    Fixture 代码 package eg; import org.joda.time.DateTime; public class JodaTime { int year; public Strin ...

  2. Spring Boot 学习系列(01)—从0到1,只需两分钟

    此文已由作者易国强授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 快速构建 如果我们想基于spring mvc 提供一个简单的API查询服务,传统的方式,首先需要我们引入sp ...

  3. c#中 这种构造方法Recer(…):this(…){ }

    指的是构造函数首先调用另外一个构造函数. class Program { static void Main(string[] args) { Person p2 = new Person(" ...

  4. [Xcode 实际操作]一、博主领进门-(12)代码重构

    目录:[Swift]Xcode实际操作 本文将演示如何重构代码. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] [快速更改同名变量或常量] 在代码编辑区域,点击需 ...

  5. 【NOIP2015】 Day2 T2 字串 (多维动归)

    2018-09-12 原题传送门(洛谷)https://www.luogu.org/problemnew/show/P2679 模拟考试的时候完全没有想到 正确的DP方程呢 本来写了一个大致是对的转移 ...

  6. 第三篇 Nosql讲解之windows下Memcached和Memcache的区别安装(二)

    一.Memcached和Memcache的区别: 网上关于Memcached和Memcache的区别的理解众说纷纭,我个人的理解是: Memcached是一个内存缓存系统,而Memcache是php的 ...

  7. vim 快速定位到文件末尾、头部

    gg           : 跳转到文件头 Shift+g   : 跳转到文件末尾 行数+gg : 跳转到指定行,例跳转到123行:123gg

  8. hashCode方法里为什么选择数字31作为生成hashCode值的乘数

    前提: 偶然的机会看到了大神的一篇博客,介绍的是hashCode()方法里为什么要用31这个数字作为生成hashCode的乘数.hashCode我在比较自定义类时曾经用到过 - 由于java默认比较的 ...

  9. [HDU1595] find the longest of the shortest

    题目链接: 点我 题意: 给定一个\(n\)个点,\(m\)条边的带权无向图,起点为\(1\),终点为\(n\),现在可以删去其中的一条边,求一种删边方案使得剩下图的最短路值最大,输出这个最短路的长度 ...

  10. Docker容器与容器数据

    Docker容器与容器数据 image 与container 镜像(Image)和容器(Container)的关系,就像是面向对象程序设计中的 类 和 实例 一样,镜像是静态的定义,容器是镜像运行时的 ...