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, ...
随机推荐
- UML设计,可以设计程序的用例图、类图、活动图等_SurfaceView
« 对Cocos2d游戏引擎有一定的了解和实践,并接触过处理3D图形和模型库的OpenGL 在进行游戏界面的绘制工作中,需要处理大量的工作,这些工作有很多共性的操作:并且对于游戏界面的切换,元素动作的 ...
- HTML和CSS的精华
今天又是周一喽,我们开始啦又一周的学习啦,想一想,在这里学习已经一个月啦,不知什么时间已经习惯啦这种生活,我应该是一个很难适应环境的人啊,但是现在在这里感觉还可以哦,可能是来到这里有自己的目标吧,所以 ...
- Django restframwork
REST介绍 全称Representational State Transfer,即表现层状态转换,如果一个架构符合REST原则,我们就称他为Restfull架构,其主要包括如下方面: 资源Resou ...
- Android英文文档翻译系列(4)——PopupWindow
public class PopupWindow extends Object //直接继承至Object java.lang.Object ↳ android.widget.PopupWindow ...
- poj_3258 二分法
题目大意 给定区间[0,L],在区间内给定N个数,加上区间的端点总共N+2个值.这N+2个数相邻的两个数之间有一个差值delta[i],现在可以从除去端点之外的这N个数中删除M个,使得剩余的N+2-M ...
- LeetCode - Delete Duplicate Emails
Discription:Write a SQL query to delete all duplicate email entries in a table named Person, keeping ...
- Android技巧分享——Android开发超好用工具吐血推荐(转)
内容中包含 base64string 图片造成字符过多,拒绝显示
- 关于layer.photos即照片显示的问题。
在layer组件中,照片显示是不常用,今天做了一些不伤了. 在这里写出来,以备后用. 其中注意几个问题, 1.格式问题. 2.路径问题. 不同的layer有不同的格式,查看layerAPI中发现的格式 ...
- bootstrap之
一.字体图标 <button type="button" class="btn btn-primary btn-lg"> <span clas ...
- chrome单步调试代码
单步调试代码 所有步骤选项均通过边栏中的可点击图标 表示,但也可以通过快捷键触发(鼠标悬停在操作图标上就可以看到快捷键).下面是简要介绍: 图标/按钮 操作 描述 Resume 继续执行直到下一个断点 ...