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, ...
随机推荐
- laravel安装 redis 并驱动 session
1)composer 安装 redis composer require predis/predis 如果感兴趣,可以看一下这里 2)配置 redis 连接(config/database.php 配 ...
- shell基础(八)-循环语句
国庆过后:感觉有点慵懒些了:接着上篇:我们继续来学习循环语句. 一. for循环 与其他编程语言类似,Shell支持for循环. for循环一般格式为: for 变量 in 列表 do command ...
- 《C++ Primer Plus》10.2 抽象和类 学习笔记
10.2.1 类型是什么基本类型完成了下面的三项工作:* 决定数据对象需要的内存数量:* 决定如何解释内存中的位(long和float在内存中占用的位数相同,但是将它们转换为数值的方法不同):* 决定 ...
- CSS3 属性组参考资料
CSS 属性组: 动画 背景 边框和轮廓 盒(框) 颜色 内容分页媒体 定位 可伸缩框 字体 生成内容 网格 超链接 行框 列表 外边距 Marquee 多列 内边距 分页媒体 定位 打印 Ruby ...
- C++ primer(十三)--类继承、构造函数成员初始化、虚函数、抽象基类
一.基类 从一个类派生出另一个类时,原始类称为基类,继承类称为派生类. 派生类对自身基类的private成员没有访问权限,对基类对象的protected成员没有访问权限,对派生类对象的(基类之 ...
- TCP关闭连接(为什么会能Time_wait,Close_wait?)
版权声明:本文由胡文斌原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/102 来源:腾云阁 https://www.qclo ...
- Android Training - 管理应用的内存
http://hukai.me/android-training-managing_your_app_memory/ Random Access Memory(RAM)在任何软件开发环境中都是一个很宝 ...
- centos配置Tomcat以指定的身份(非root)运行
本文依赖的环境: 已安装并配置好jdk和tomcat环境 已安装并配置好gcc.make等编译工具 1.编译安装守护程序 cd /usr/local/tomcat7/bin/ tar vzxf c ...
- vector容器建图
#pragma comment(linker, "/STACK:1024000000,1024000000") #include"stdio.h" #inclu ...
- 170620、springboot编程之页面版Hello World
书接上回,把Hello World 在页面上显示! 1.在pom文件中加入web支持 <dependency> <groupId>org.springframework.boo ...