杭电多校第九场 hdu6424 Rikka with Time Complexity 数学
Rikka with Time Complexity
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 448 Accepted Submission(s): 159
This semester, Rikka applies for the assistant of course "Algorithm Analysis". Now Rikka needs to set problems for the final examination, and she is going to set some tasks about time complexity.
Let fa(n)=log…logn (there are exactly a log in this function, and log uses base 2). And then, for an integer array A, Rikka defines gA(n) in the following way (B is the suffix of A with length |A|−1):
For example, g[1,2](n)=(logn)loglogn and g[3,1,1](n)=(logloglogn)(logn)logn.
Now, given integer arrays A and B, Rikka wants you to compare gA(n) with gB(n). i.e., let k be limn→+∞gA(n)gB(n). If k=0, output −1; if k=+∞, output 1; otherwise output 0.
For each testcase, the first line contains two integers a,b(1≤a,b≤3), the length of A and B.
The second line contains a integers Ai and the third line contains b integers Bi(1≤Ai,Bi≤109), which describe A and B.
1 1
1
2
2 2
1 2
2 1
1 3
1
1000000000 3 3
-1
-1
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e5+10;
const double eps = 1e-8;
const ll mod = 998244353;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
void getmin(ll *a) {
if( min(a[0],a[1]) == min(a[2],a[3]) ) {
if( max(a[0],a[1]) >= max(a[2],a[3]) ) {
swap(a[0],a[2]), swap(a[1],a[3]);
}
} else if( min(a[0],a[1]) > min(a[2],a[3]) ) {
swap(a[0],a[2]), swap(a[1],a[3]);
}
if( a[0] > a[1] ) {
swap(a[0],a[1]);
}
if( a[2] > a[3] ) {
swap(a[2],a[3]);
}
}
int main() {
ios::sync_with_stdio(0);
ll T;
cin >> T;
while( T -- ) {
ll a, b, A[4] = {0}, B[4] = {0};
cin >> a >> b;
for( ll i = 1; i <= a; i ++ ) {
cin >> A[i];
}
for( ll i = 1; i <= b; i ++ ) {
cin >> B[i];
}
A[0] = inf, B[0] = inf;
for( ll i = 1; i <= 3; i ++ ) {
if(A[i]) {
A[i] += 3-i;
} else {
A[i] = inf;
}
if(B[i]) {
B[i] += 3-i;
} else {
B[i] = inf;
}
}
getmin(A),getmin(B);
ll ans = 0;
for( ll i = 0; i <= 3; i ++ ) {
if( A[i] == B[i] ) {
continue;
}
if( A[i] < B[i] ) {
ans = 1;
break;
} else if( A[i] > B[i] ) {
ans = -1;
break;
}
}
cout << ans << endl;
}
return 0;
}
杭电多校第九场 hdu6424 Rikka with Time Complexity 数学的更多相关文章
- 杭电多校第九场 hdu6425 Rikka with Badminton 组合数学 思维
Rikka with Badminton Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/O ...
- 杭电多校第九场 HDU6415 Rikka with Nash Equilibrium dp
Rikka with Nash Equilibrium Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 524288/524288 K ...
- 杭电多校第九场 D Rikka with Stone-Paper-Scissors 数学
Rikka with Stone-Paper-Scissors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/52428 ...
- 2018 Multi-University Training Contest 9 杭电多校第九场 (有坑待补)
咕咕咕了太久 多校博客直接从第三场跳到了第九场orz 见谅见谅(会补的!) 明明最后看下来是dp场 但是硬生生被我们做成了组合数专场…… 听说jls把我们用组合数做的题都用dp来了遍 这里只放了用组 ...
- Rikka with Game[技巧]----2019 杭电多校第九场:1005
Rikka with Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Othe ...
- Rikka with Travels(2019年杭电多校第九场07题+HDU6686+树形dp)
目录 题目链接 题意 思路 代码 题目链接 传送门 题意 定义\(L(a,b)\)为结点\(a\)到结点\(b\)的路径上的结点数,问有种\(pair(L(a,b),L(c,d))\)取值,其中结点\ ...
- 2019杭电多校第⑨场B Rikka with Cake (主席树,离散化)
题意: 给定一块n*m的矩形区域,在区域内有若干点,每个顶点发出一条射线,有上下左右四个方向,问矩形被分成了几个区域? 思路: 稍加观察和枚举可以发现,区域数量=射线交点数+1(可以用欧拉定理验证,但 ...
- 2018 Multi-University Training Contest 1 杭电多校第一场
抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001 Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...
- 2018 Multi-University Training Contest 2 杭电多校第二场
开始逐渐习惯被多校虐orz 菜是原罪 1004 Game (hdoj 6312) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6312 虽然披着 ...
随机推荐
- 【部分转载】:【lower_bound、upperbound讲解、二分查找、最长上升子序列(LIS)、最长下降子序列模版】
二分 lower_bound lower_bound()在一个区间内进行二分查找,返回第一个大于等于目标值的位置(地址) upper_bound upper_bound()与lower_bound() ...
- Django是如何防止注入攻击-XSS攻击-CSRF攻击
注入攻击-XSS攻击-CSRF攻击介绍请访问:https://www.cnblogs.com/hwnzy/p/11219475.html Django防止注入攻击 Django提供一个抽象的模型层来组 ...
- c#图片的平移与旋转
1新建文件夹,添加一个图片 2 添加控件 两个button控件 一个image控件 一个Canvas控件 3 代码实现 using System;using System.Collections.Ge ...
- 【POJ - 2236】Wireless Network (并查集)
Wireless Network 这接翻译了 Descriptions 地震发生在东南亚.ACM(亚洲合作医疗团队)已经与膝上电脑建立了无线网络,但是一次意外的余震袭击,网络中的所有计算机都被打破了. ...
- 算法与数据结构基础 - 位运算(Bit Manipulation)
位运算基础 说到与(&).或(|).非(~).异或(^).位移等位运算,就得说到位运算的各种奇淫巧技,下面分运算符说明. 1. 与(&) 计算式 a&b,a.b各位中同为 1 ...
- Eclipse高级操作 远程调试
Eclipse高级操作 远程调试 JPDA是SUN JDK自带的远程调试机制.它提供了一套标准的调试接口,可以从虚拟机一级允许外界用特定协议探测虚拟机内部的运作细节.只要你装了JDK1.2以上的SUN ...
- 源码解读 Spring Boot Profiles
前言 上文<一文掌握 Spring Boot Profiles> 是对 Spring Boot Profiles 的介绍和使用,因此本文将从源码角度探究 Spring Boot Profi ...
- hadoop2.7作业提交详解之文件分片
在前面一篇文章中(hadoop2.7之作业提交详解(上))中涉及到文件的分片. JobSubmitter.submitJobInternal方法中调用了int maps = writeSplits(j ...
- 初学html总结
2019-08-17 17:58:49 html:超文本标记语言,用于网页结构的搭建 html语言构成:由标签.属性.属性值构成 标签:" < "后面第一个单词 属性:标签后 ...
- 线程的start方法解析
Thread是学习我们学习多线程接触到的第一个有关多线程的类,相信每一个学习过或者了解过Java多线程的小伙伴都知道Thread类.这次分享主要对Thread的start方法进行讲解. 相信大家都知道 ...