Lyft Level 5 Challenge 2018 - Elimination Round
A. King Escape
签.
#include <bits/stdc++.h>
using namespace std; int n, x[], y[]; int f1(int X, int Y)
{
return X - Y - x[] + y[];
} int f2(int X, int Y)
{
return x[] + y[] - X - Y;
} bool ok()
{
//if (f1(x[0], y[0]) * f1(x[1], y[1]) < 0) return false;
//if (f2(x[0], y[0]) * f2(x[1], y[1]) < 0) return false;
if (x[] > x[]) swap(x[], x[]);
if (y[] > y[]) swap(y[], y[]);
if (y[] >= y[] && y[] <= y[]) return false;
if (x[] >= x[] && x[] <= x[]) return false;
return true;
} int main()
{
while (scanf("%d", &n) != EOF)
{
scanf("%d%d", x + , y + );
for (int i = ; i < ; ++i)
scanf("%d%d", x + i, y + i);
puts(ok() ? "YES" : "NO");
}
return ;
}
B. Square Difference
签.
#include <bits/stdc++.h>
using namespace std; #define ll long long
int t; ll a, b; bool ok(ll x)
{
ll limit = sqrt(x);
for (ll i = ; i <= limit && i < x; ++i)
if (x % i == )
return false;
return true;
} int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%lld%lld", &a, &b);
if (a - b != ) puts("NO");
else
puts(ok(a + b) ? "YES" : "NO");
}
return ;
}
C. Permutation Game
Solved.
题意:
$A和B玩游戏,一个人能从i移动到j$
$当且仅当a[i] < a[j] 并且|i - j| \equiv 0 \pmod a[i]$
$判断以每个数为下标作起点,A先手能否必胜$
思路:
我们考虑一个位置什么时候必败
- $它下一步没有可移动的位置$
- $它的下一步状态没有一处是必败态$
倒着处理出每个位置的状态即可
#include <bits/stdc++.h>
using namespace std; #define N 100010
int n, a[N], ans[N], pos[N]; int main()
{
while (scanf("%d", &n) != EOF)
{
for (int i = ; i <= n; ++i) scanf("%d", a + i), pos[a[i]] = i;
for (int i = n; i >= ; --i)
{
int id = pos[i];
bool flag = ;
for (int j = id - i; j >= ; j -= i)
if (a[j] > i && ans[a[j]] == )
{
flag = ;
break;
}
if (flag == ) for (int j = id + i; j <= n; j += i)
if (a[j] > i && ans[a[j]] == )
{
flag = ;
break;
}
ans[i] = flag;
}
for (int i = ; i <= n; ++i)
putchar(ans[a[i]] ? 'A' : 'B');
puts("");
}
return ;
}
D. Divisors
Upsolved.
题意:
给出一些$a_i, 求 \prod a_i 的因子个数$
$保证a_i 有3-5个因数$
思路:
对一个数求因子个数 假设它质因数分解之后是$n = p_1^{t_1} \cdot p_2^{t_2} \cdots p_n^{t_n}$
那么因子个数就是$(t_1 + 1) \cdot (t_2 + 1) \cdots (t_n + 1)$
我们考虑什么样的数有$3-5个因数$
$平方数、立方数、四次方数、n = p \cdot q (p, q 是不同的质数)$
$对于前三类数,可以暴力破出,考虑第四类$
$如果它的p, q在序列中是唯一的,那么我们不需要管它具体是多少$
$直接得到p, q的数量就是这个数的数量$
$否则,拿这个数和别的数作gcd就可以破出p, q$
#include <bits/stdc++.h>
using namespace std; #define ll long long
#define N 1010
const ll MOD = (ll);
int n; ll a[N];
map <ll, int> mp, num; void work(ll a)
{
ll limit = pow(a, 1.0 / );
for (ll i = limit + ; i >= limit - && i >= ; --i)
if (i * i * i * i == a)
{
mp[i] += ;
return;
}
limit = pow(a, 1.0 / );
for (ll i = limit + ; i >= limit - && i >= ; --i)
if (i * i * i == a)
{
mp[i] += ;
return;
}
limit = pow(a, 1.0 / );
for (ll i = limit + ; i >= limit - && i >= ; --i)
if (i * i == a)
{
mp[i] += ;
return;
}
++num[a];
} ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } int main()
{
while (scanf("%d", &n) != EOF)
{
mp.clear(); num.clear();
for (int i = ; i <= n; ++i)
{
scanf("%lld", a + i);
work(a[i]);
}
ll res = ;
for (auto it : num)
{
ll tmp;
bool flag = true;
for (int i = ; i <= n; ++i)
if (a[i] != it.first && (tmp = gcd(it.first, a[i])) != )
{
mp[tmp] += it.second;
mp[it.first / tmp] += it.second;
flag = false;
break;
}
if (flag) res = (res * (it.second + ) % MOD * (it.second + )) % MOD;
}
for (auto it : mp)
res = (res * (it.second + )) % MOD;
printf("%lld\n", res);
fflush(stdout);
}
return ;
}
Lyft Level 5 Challenge 2018 - Elimination Round的更多相关文章
- [Lyft Level 5 Challenge 2018 - Elimination Round][Codeforces 1033D. Divisors]
题目链接:1033D - Divisors 题目大意:给定\(n\)个数\(a_i\),每个数的约数个数为3到5个,求\(\prod_{i=1}^{n}a_i\)的约数个数.其中\(1 \leq n ...
- Lyft Level 5 Challenge 2018 - Elimination Round翻车记
打猝死场感觉非常作死. A:判一下起点和终点是否在其两侧即可. #include<iostream> #include<cstdio> #include<cmath> ...
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) (前三题题解)
这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你 ...
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) B 1075B (思维)
B. Taxi drivers and Lyft time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2)---ABC
A---The King's Race http://codeforces.com/contest/1075/problem/A 题意: 一个人在\((1,1)\), 一个人在\((n,n)\), 现 ...
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2)
A. The King's Race 签. #include <bits/stdc++.h> using namespace std; #define ll long long ll n, ...
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) C. The Tower is Going Home(思维+双指针)
https://codeforces.com/contest/1075/problem/C 题意 一个宽为1e9*1e9的矩阵中的左下角,放置一个车(车可以移动到同一行或同一列),放置一些墙,竖的占据 ...
- Lyft Level 5 Challenge 2018 - Final Round Div. 1没翻车记
夜晚使人着迷.没有猝死非常感动. A:显然对于水平线段,只有横坐标的左端点为1的时候才可能对答案产生影响:对于竖直直线,如果要删一定是删去一段前缀.枚举竖直直线删到哪一条,记一下需要删几条水平线段就可 ...
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) A. The King's Race
http://codeforces.com/contest/1075/problem/A On a chessboard with a width of nn and a height of nn, ...
随机推荐
- Python 练习题:计算 MAC 地址
#!/usr/bin/env python #-*- coding:utf-8 -*- ''' 给一个MAC地址加1 ''' mac = '52:54:00:e6:b2:0a' prefix_mac ...
- M0 M4之GPIO初始化
新唐所有的M0/M4芯片基本上所有的IO都可以发生中断,为了符合大家的习惯还是有所谓的外部中断EINT0和EINT1.有2跟GPIO脚可以配置为EINT0功能和EINT1功能,分别将发生EINT0中断 ...
- 多字节(一般指GBK) utf8 Unicode 编码互转
// c:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\WinNls.h #define CP_ACP 0 // default to ANS ...
- 《C++ Primer Plus》15.1 友元 学习笔记
15.1.1 友元类假定需要编写一个模拟电视机和遥控器的简单程序.决定定义一个Tv类和一个Remote类,来分别表示电视机和遥控器.遥控器和电视机之间既不是is-a关系也不是has-a关系.事实上,遥 ...
- JS面向对象编程学习
学习目标:1.掌握JS中的类(原型对象)和对象.2.什么是成员变量和成员方法.3.掌握构造方法的使用.补充:关于双等号(==):1.如果等号两边都是字符串时,则比较内容是否相等2.如果等号两边是数字时 ...
- WEB安全第二篇--用文件搞定服务器:任意文件上传、文件包含与任意目录文件遍历
零.前言 最近做专心web安全有一段时间了,但是目测后面的活会有些复杂,涉及到更多的中间件.底层安全.漏洞研究与安全建设等越来越复杂的东东,所以在这里想写一个系列关于web安全基础以及一些讨巧的pay ...
- Minix2.0操作系统公用头文件说明
以下头文件均在目录include/下: ansi.h: 用来检测编译器是否遵循标准C,如果是的话,_ANSI就被定义为31415,如果不是的,则_ANSI未定义.通过这个宏来诊测. limits.h: ...
- [C/C++] String Reverse 字符串 反转
#include <iostream> #include <string> #include <algorithm> #include <cstring> ...
- java GC工作机制
转自:http://www.cnblogs.com/hzdtf/articles/5419987.html GC:垃圾回收站,是将java的无用的堆对象进行清理,释放内存,以免发生内存泄露.在介绍ja ...
- apache工作模式worker以及prefork的切换
apache比较常用的工作模式有worker以及prefork两种方式. 如果在编译时候不指定,系统默认的是prefork模式:如果需要换成worker模式,需要在编译的时候带上编译参数:--with ...