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, ...
随机推荐
- swift开发之--UISearchBar的使用/UISearchController的使用
记录下UISearchBar的基本用法,补充:ios 8.0以后,原来的UISearchDisplayController被官方废弃,建议使用UISearchController,下面就简单的记录下这 ...
- GeoServer安装说明-OpenSpirit
一.安装步骤 1.安装JDK: 2.安装Tomcat:(本测试过程使用JspStudy,需要进行端口设置,并指定Web目录,如:D:\JspStudy\tomcat\webapps) 3.拷贝geos ...
- python2.0_day19_充分使用Django_form实现前端操作后台数据库
在前面的<python2.0_day19_学员管理系统之前端用户交互系统>一节中,我们实现了前端展示customer客户纪录.在<python2.0_day19_前端分页功能的实现& ...
- osgearth将视点绑定到一个节点上
_manip->getSettings()->setTetherMode(osgEarth::Util::EarthManipulator:: TETHER_CENTER ); //设置_ ...
- (一)微信小程序之模拟调用后台接口踩过的坑
如下图标记的三个点 在调试过程中出现问题,特此记录. 1. 之前在浏览器测试接口习惯省略 http:// ,是因为浏览器默认有一个检测,在你输入的网址前面加http://,如果有就不加. 然而在微信小 ...
- Oracle里 用sql*plus 登陆时,用户名和密码是多少啊?
Oracle里sql*plus的用户名即system用户,密码是自己设置的密码. 如果密码忘记,可通过如下方法重置. 1.win键+R键,输入cmd,打开命令提示符. 2.输入sqlplus /nol ...
- 关于sencha touch 用phonegap打包后,docked悬停的组件被手机软键盘遮挡的解决方法
这个问题应该算是phonegap的一个bug,在mainifest.xml 里android:windowSoftInputMode设置成了adjustpan,理论上不会出现遮挡悬停组件这种情况, 不 ...
- c# 计算文字高度
SizeF sizeF = g.MeasureString(listBox1.Items[e.Index].ToString(), e.Font, listBox1.Width);
- Mac - 如何在windows下打开 pages
1.iCloud 苹果邮箱网页版打开(www.icloud.com) 2.在pages编辑完后,导出word格式.便能继续编辑.修改文档内容,有小部分字体.设计会在导出word格式后发生改变. 3.导 ...
- 边的双联通+缩点+LCA(HDU3686)
Traffic Real Time Query System Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...