牛客多校训练AFJ(签到)
题目链接https://ac.nowcoder.com/acm/contest/881/A(单调栈)
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
int L1[*maxn],L2[*maxn];
int a[*maxn],b[*maxn];
int main()
{
int n;
while(~scanf("%d",&n))
{
for(int t=;t<=n;t++)
{
scanf("%d",&a[t]);
}
for(int t=;t<=n;t++)
{
scanf("%d",&b[t]);
}
stack<int>s1,s2;
for(int t=;t<=n;t++)
{
if(s1.empty())
{
L1[t]=;
s1.push(t);
continue;
}
else
{
while(!s1.empty()&&a[s1.top()]>a[t])
{
s1.pop();
}
if(s1.empty())
{
L1[t]=;
s1.push(t);
continue;
}
else
{
L1[t]=s1.top();
s1.push(t);
continue;
}
}
}
for(int t=;t<=n;t++)
{
if(s2.empty())
{
L2[t]=;
s2.push(t);
continue;
}
else
{
while(!s2.empty()&&b[s2.top()]>b[t])
{
s2.pop();
}
if(s2.empty())
{
L2[t]=;
s2.push(t);
continue;
}
else
{
L2[t]=s2.top();
s2.push(t);
continue;
}
}
}
int k=n+;
for(int t=;t<=n;t++)
{
//cout<<L1[k]<<" "<<L2[k]<<endl;
if(L1[t]!=L2[t]){
k=t;
break;
}
}
printf("%d\n",k-); }
return ;
}
题目链接:https://ac.nowcoder.com/acm/contest/881/F(思维)
三角形面积的22倍
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
int main()
{ long double x0,y0,x1,y1,x2,y2;
long double a,b,c,p,S;
long double ans;
while(cin>>x0>>y0>>x1>>y1>>x2>>y2)
{
a=sqrtl((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
b=sqrtl((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2));
c=sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
//cout<<a<<" "<<b<<" "<<c<<endl;
p=(a+b+c)/;
S=sqrtl(p*(p-a)*(p-b)*(p-c));
S=S*;
ans=S;
printf("%.0Lf\n",ans);
} return ;
}
海伦公式版没过 不知道原因
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
int main()
{ long double x0,y0,x1,y1,x2,y2;
long double a,b,c,p,S;
long double ans;
while(cin>>x0>>y0>>x1>>y1>>x2>>y2)
{
a=sqrtl((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
b=sqrtl((x0-x2)*(x0-x2)+(y0-y2)*(y0-y2));
c=sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
//cout<<a<<" "<<b<<" "<<c<<endl;
p=(a+b+c)/;
S=sqrtl(p*(p-a)*(p-b)*(p-c));
S=S*;
ans=S;
printf("%.0Lf\n",ans);
} return ;
}
题目链接:https://ac.nowcoder.com/acm/contest/881/J(大数)
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std; const int maxn = ; struct bign{
int d[maxn], len; void clean() { while(len > && !d[len-]) len--; } bign() { memset(d, , sizeof(d)); len = ; }
bign(int num) { *this = num; }
bign(char* num) { *this = num; }
bign operator = (const char* num){
memset(d, , sizeof(d)); len = strlen(num);
for(int i = ; i < len; i++) d[i] = num[len--i] - '';
clean();
return *this;
}
bign operator = (int num){
char s[]; sprintf(s, "%d", num);
*this = s;
return *this;
} bign operator + (const bign& b){
bign c = *this; int i;
for (i = ; i < b.len; i++){
c.d[i] += b.d[i];
if (c.d[i] > ) c.d[i]%=, c.d[i+]++;
}
while (c.d[i] > ) c.d[i++]%=, c.d[i]++;
c.len = max(len, b.len);
if (c.d[i] && c.len <= i) c.len = i+;
return c;
}
bign operator - (const bign& b){
bign c = *this; int i;
for (i = ; i < b.len; i++){
c.d[i] -= b.d[i];
if (c.d[i] < ) c.d[i]+=, c.d[i+]--;
}
while (c.d[i] < ) c.d[i++]+=, c.d[i]--;
c.clean();
return c;
}
bign operator * (const bign& b)const{
int i, j; bign c; c.len = len + b.len;
for(j = ; j < b.len; j++) for(i = ; i < len; i++)
c.d[i+j] += d[i] * b.d[j];
for(i = ; i < c.len-; i++)
c.d[i+] += c.d[i]/, c.d[i] %= ;
c.clean();
return c;
}
bign operator / (const bign& b){
int i, j;
bign c = *this, a = ;
for (i = len - ; i >= ; i--)
{
a = a* + d[i];
for (j = ; j < ; j++) if (a < b*(j+)) break;
c.d[i] = j;
a = a - b*j;
}
c.clean();
return c;
}
bign operator % (const bign& b){
int i, j;
bign a = ;
for (i = len - ; i >= ; i--)
{
a = a* + d[i];
for (j = ; j < ; j++) if (a < b*(j+)) break;
a = a - b*j;
}
return a;
}
bign operator += (const bign& b){
*this = *this + b;
return *this;
} bool operator <(const bign& b) const{
if(len != b.len) return len < b.len;
for(int i = len-; i >= ; i--)
if(d[i] != b.d[i]) return d[i] < b.d[i];
return false;
}
bool operator >(const bign& b) const{return b < *this;}
bool operator<=(const bign& b) const{return !(b < *this);}
bool operator>=(const bign& b) const{return !(*this < b);}
bool operator!=(const bign& b) const{return b < *this || *this < b;}
bool operator==(const bign& b) const{return !(b < *this) && !(b > *this);} string str() const{
char s[maxn]={};
for(int i = ; i < len; i++) s[len--i] = d[i]+'';
return s;
}
}; istream& operator >> (istream& in, bign& x)
{
string s;
in >> s;
x = s.c_str();
return in;
} ostream& operator << (ostream& out, const bign& x)
{
out << x.str();
return out;
}
int main()
{
bign x,y,a,b;
while(cin>>x>>a>>y>>b)
{
if(x*b==y*a)
{
puts("=");
}
else if(x*b<y*a)
{
puts("<");
}
else
{
puts(">");
}
}
}
牛客多校训练AFJ(签到)的更多相关文章
- 牛客多校训练第八场G.Gemstones(栈模拟)
题目传送门 题意: 输入一段字符串,字符串中连续的三个相同的字符可以消去,消去后剩下的左右两段字符串拼接,求最多可消去次数. 输入:ATCCCTTG 输出:2 ATCCCTTG(消去CCC)——& ...
- 牛客多校训练第八场C.CDMA(思维+构造)
题目传送门 题意: 输入整数m( m∈2k ∣ k=1,2,⋯,10),构造一个由1和-1组成的m×m矩阵,要求对于任意两个不同的行的内积为0. 题解: Code: #include<bits/ ...
- 2019牛客多校训练第四场K.number(思维)
题目传送门 题意: 输入一个只包含数字的字符串,求出是300的倍数的子串的个数(不同位置的0.00.000等都算,并考虑前导零的情况). sample input: 600 1230003210132 ...
- 2019牛客多校训练第三场H.Magic Line(思维)
题目传送门 大致题意: 输入测试用例个数T,输入点的个数n(n为偶数),再分别输入n个不同的点的坐标,要求输出四个整数x1,y1,x2,y2,表示有一条经过点(x1,y1),(x2,y2)的直线将该二 ...
- 2019牛客多校训练第三场B.Crazy Binary String(思维+前缀和)
题目传送门 大致题意: 输入整数n(1<=n<=100000),再输入由n个0或1组成的字符串,求该字符串中满足1和0个数相等的最长子串.子序列. sample input: 801001 ...
- 18牛客多校训练第二场 J farm
题意:一个n×m的农田, 每个小格子都有一种作物, 现在喷t次农药,每次农药覆盖一个矩形, 该矩形里面与农药类型不同的植物都会死掉, 求最后植物的死亡数是多少. 题解:二维树状数组. 每次喷农药的时候 ...
- 2019暑假牛客多校训练-第八场-C-CDMA(递归、水题)
观察前3组可以推出递归规律,生成下一个类型时,每行copy自身与自身相反. 题目描述 Gromah and LZR have entered the third level. There is a b ...
- 2019牛客多校第一场 I Points Division(动态规划+线段树)
2019牛客多校第一场 I Points Division(动态规划+线段树) 传送门:https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点有 ...
- 牛客多校第一场 B Inergratiion
牛客多校第一场 B Inergratiion 传送门:https://ac.nowcoder.com/acm/contest/881/B 题意: 给你一个 [求值为多少 题解: 根据线代的知识 我们可 ...
随机推荐
- python 正则表达式与JSON-正则表达式匹配数字、非数字、字符、非字符、贪婪模式、非贪婪模式、匹配次数指定等
1.正则表达式:目的是为了爬虫,是爬虫利器. 正则表达式是用来做字符串匹配的,比如检测是不是电话.是不是email.是不是ip地址之类的 2.JSON:外部数据交流的主流格式. 3.正则表达式的使用 ...
- PHP入门之数组
前言 之前几篇文章分别介绍了PHP的运算符,流程控制,函数.有兴趣的可以去看看. PHP入门之类型与运算符 PHP入门之流程控制 PHP入门之函数 接下来简单介绍一下数组. 数组初探 为什么要引进数组 ...
- Dubbo系列之 (一)SPI扩展
一.基础铺垫 1.@SPI .@Activate. @Adaptive a.对于 @SPI,Dubbo默认的特性扩展接口,都必须打上这个@SPI,标识这是个Dubbo扩展点.如果自己需要新增dubbo ...
- Docker容器网络-实现篇
通常,Linux容器的网络是被隔离在它自己的Network Namespace中,其中就包括:网卡(Network Interface).回环设备(Loopback Device).路由表(Routi ...
- Java环境变量配置,HelloWorld。
一 配置环境变量: 1.右键计算机属性 2.点击高级系统设置 3.点击环境变量 在新建页面,输入变量名“JAVA_HOME”:变量值“你的jdk的路径 在系统变量区域,选择“新建”,输入变量名“CL ...
- MySQL“被动”性能优化汇总!
年少不知优化苦,遇坑方知优化难. --村口王大爷 本文内容导图如下: 我之前有很多文章都在讲性能优化的问题,比如下面这些: <switch 的性能提升了 3 倍,我只用了这一招!> < ...
- 2020-07-05:tcp和udp的区别和应用场景。如何实现断点续传?
福哥答案2020-07-05: 区别:1.可靠性:tcp可靠.udp不可靠.2.连接性:tcp面向连接.udp无连接.3.报文:tcp字节流.udp面向报文.4.传输效率:tcp低.udp高.5.多点 ...
- 为什么我们需要Q#?
原文地址:https://blogs.msdn.microsoft.com/visualstudio/2018/11/15/why-do-we-need-q/ 本文章为机器翻译. 你可能熟悉微软量子的 ...
- 编译原理——求解First,Follow,Firstvt和Lastvt集合
转载地址 http://dongtq2010.blog.163.com/blog/static/1750224812011520113332714/ 学编译原理的时候,印象最深的莫过于这四个集合了,而 ...
- vue自定义可输入的选择框组件
vue自定义可输入的选择框组件 props: 属性 说明 类型 默认值 selectDataList 下拉框中的内容 Array 空数组([]) value 输入框中的内容 String 空字符串(& ...