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 -- 如何在swift下,使用类似oc的pch文件功能
以前在做oc下的项目的时候,pch文件是必创建的,因为实在是太方便了,只要在build setting里面把pch的路径换成绝对路径,那么剩下的,想干什么就在里面干什么,但是swift下,可以实现这种 ...
- python2.0_s12_day13_javascript&Dom&jQuery
今天主要内容:JavaScriptDomjQuery http://www.cnblogs.com/wupeiqi/articles/5369773.html 今天主要内容大致了解:javascrip ...
- python远程登录服务器(paramiko模块安装和使用)
转自:http://www.jb51.net/article/46285.htm 一:简介 由paramiko是用python语言写的一个模块,遵循SSH2协议,支持以加密和认证的方式,进行远程服务器 ...
- iOS - UIImageView - how to handle UIImage image orientation
本文转载至 http://stackoverflow.com/questions/8915630/ios-uiimageview-how-to-handle-uiimage-image-orienta ...
- Postgresql 创建主键并设置自动递增的三种方法
Postgresql 有以下三种方法设置主键递增的方式,下面来看下相同点和不同点. --方法一create table test_a ( id serial, name character var ...
- C、C++编程入口,常见的编程题
1.设计一个从5个数中取最小数和最大数的程序. 2.#include<stdio.h> 3.int min(int a[],int i); 4.int max(int a[],int i) ...
- SASS环境搭建及HBuilder中sass预编译配置
---------------------------------Ruby环境安装-------------------------------- 至于为什么要安装ruby环境请移步:https:// ...
- Java多线程详解(三)
1)死锁 两个线程相互等待对方释放同步监视器时会出现死锁的现象,这时所有的线程都处于阻塞状态,程序无法继续向下执行. 如下就是会出现死锁的程序. 首先flag = 1,线程d1开始执行,锁住对象o1, ...
- SPF难以解决邮件伪造的现状以及方案
邮件伪造的现状 仿冒域名 私搭邮服仿冒域名: 例如某公司企业的域名是example.com,那么攻击者可以搭建一个邮服,也把自己的域名配置为example.com,然后发邮件给真实的企业员工xxx@e ...
- 域渗透学习预备知识-IPC$的入侵防御
一.什么是IPC$ 以下段落引文自:http://www.xfocus.net/articles/200303/493.html IPC$(Internet Process Connection)是共 ...