牛客多校训练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+5; typedef long long ll; using namespace std; int L1[5*maxn],L2[5*maxn]; int a[5*maxn],b[5*maxn]; int main() {int n;while(~scanf("%d",&n)){for(int t=1;t<=n;t++){scanf("%d",&a[t]);}for(int t=1;t<=n;t++){scanf("%d",&b[t]);}stack<int>s1,s2; for(int t=1;t<=n;t++){if(s1.empty()){L1[t]=0;s1.push(t);continue;}else{while(!s1.empty()&&a[s1.top()]>a[t]){s1.pop();}if(s1.empty()){L1[t]=0;s1.push(t);continue;}else{L1[t]=s1.top();s1.push(t);continue;} }}for(int t=1;t<=n;t++){if(s2.empty()){L2[t]=0;s2.push(t);continue;}else{while(!s2.empty()&&b[s2.top()]>b[t]){s2.pop();}if(s2.empty()){L2[t]=0;s2.push(t);continue;}else{L2[t]=s2.top();s2.push(t);continue;} }}int k=n+1;for(int t=1;t<=n;t++){//cout<<L1[k]<<" "<<L2[k]<<endl;if(L1[t]!=L2[t]){k=t;break;} }printf("%d\n",k-1);}return 0; }
题目链接: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+5; 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)/2;S=sqrtl(p*(p-a)*(p-b)*(p-c));S=S*22;ans=S; printf("%.0Lf\n",ans);}return 0; }
海伦公式版没过 不知道原因
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<queue> #include<stack> #include<set> #include<vector> #include<map> #include<cmath> const int maxn=1e5+5; 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)/2;S=sqrtl(p*(p-a)*(p-b)*(p-c));S=S*22;ans=S;printf("%.0Lf\n",ans);}return 0; }
题目链接: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 = 1000; struct bign{ int d[maxn], len; void clean() { while(len > 1 && !d[len-1]) len--; } bign() { memset(d, 0, sizeof(d)); len = 1; } bign(int num) { *this = num; } bign(char* num) { *this = num; } bign operator = (const char* num){ memset(d, 0, sizeof(d)); len = strlen(num); for(int i = 0; i < len; i++) d[i] = num[len-1-i] - '0'; clean(); return *this; } bign operator = (int num){ char s[20]; sprintf(s, "%d", num); *this = s; return *this; } bign operator + (const bign& b){ bign c = *this; int i; for (i = 0; i < b.len; i++){ c.d[i] += b.d[i]; if (c.d[i] > 9) c.d[i]%=10, c.d[i+1]++; } while (c.d[i] > 9) c.d[i++]%=10, c.d[i]++; c.len = max(len, b.len); if (c.d[i] && c.len <= i) c.len = i+1; return c; } bign operator - (const bign& b){ bign c = *this; int i; for (i = 0; i < b.len; i++){ c.d[i] -= b.d[i]; if (c.d[i] < 0) c.d[i]+=10, c.d[i+1]--; } while (c.d[i] < 0) c.d[i++]+=10, 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 = 0; j < b.len; j++) for(i = 0; i < len; i++) c.d[i+j] += d[i] * b.d[j]; for(i = 0; i < c.len-1; i++) c.d[i+1] += c.d[i]/10, c.d[i] %= 10; c.clean(); return c; } bign operator / (const bign& b){ int i, j; bign c = *this, a = 0; for (i = len - 1; i >= 0; i--) { a = a*10 + d[i]; for (j = 0; j < 10; j++) if (a < b*(j+1)) break; c.d[i] = j; a = a - b*j; } c.clean(); return c; } bign operator % (const bign& b){ int i, j; bign a = 0; for (i = len - 1; i >= 0; i--) { a = a*10 + d[i]; for (j = 0; j < 10; j++) if (a < b*(j+1)) 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-1; i >= 0; 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 = 0; i < len; i++) s[len-1-i] = d[i]+'0'; 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(">");}} }
转载于:https://www.cnblogs.com/Staceyacm/p/11210802.html
牛客多校训练AFJ(签到)相关推荐
- 2019牛客多校训练第十场F Popping Balloons
2019牛客多校训练第十场F Popping Balloons 题意:二维平面内给你若干个点,然后你可以在x轴和y轴分别射三枪(每一枪的间隔是R),问最多能射掉多少气球. 题解:贪心.这个应该只能算作 ...
- [2019牛客多校训练第3场]Median
链接:https://ac.nowcoder.com/acm/contest/883/I 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
- 【2020暑假牛客多校(一)】
牛客多校 Home AC:2,rank517AC : 2, rank517AC:2,rank517 7.127.127.12 题单 F(1271/5027)F(1271/5027)F(1271/502 ...
- 牛客多校三 B Black and white
牛客多校三 B Black and white 在n*m的棋盘上,每个格子有一个数,初始可以选一定的格子标记为黑色,在任意四个形如(i1, j1)(i1, j2)(i2, j1)(i2, j2)的格子 ...
- 2019牛客多校第一场
2019牛客多校第一场 题号 题目 知识点 A Monotonic Matrix B Symmetric Matrix C Fluorescent 2 D Two Graphs E Removal F ...
- LCS(2021牛客多校4)
LCS(2021牛客多校4) 题意: 让你构造三个字符串s1,s2,s3,长度均为n,要求LCS(s1,s2)=a,LCS(s2,s3)=b,LCS(s1,s3)=c 题解: 先考虑三个串互相LCS为 ...
- 24dian(牛客多校第三场)
24dian(牛客多校第三场) 题意: 给你n张牌,每张牌的大小为1 ~ 13,问这些牌与加减乘除任意组合(可以使用括号),且但所有的有效解在计算过程中都涉及到分数,即非整数,能否组成答案m,如果可以 ...
- 2018年牛客多校算法寒假训练营练习比赛(第一场)C. 六子冲
2018年牛客多校算法寒假训练营练习比赛(第一场)C. 六子冲 题目链接 做法:模拟即可 #include <bits/stdc++.h> #define P pair<int,in ...
- 2019牛客多校第四场 I题 后缀自动机_后缀数组_求两个串de公共子串的种类数
目录 求若干个串的公共子串个数相关变形题 对一个串建后缀自动机,另一个串在上面跑同时计数 广义后缀自动机 后缀数组 其他:POJ 3415 求两个串长度至少为k的公共子串数量 @(牛客多校第四场 I题 ...
- 2022牛客多校(十)
2022牛客多校(十) 一.比赛小结 比赛链接:"蔚来杯"2022牛客暑期多校训练营10 二.题目分析及解法(基础题) F.Shannon Switching Game? 题目链接 ...
最新文章
- static用法总结
- 博客作业2---线性表
- 泛型委托Action与ActionT
- gc()两分钟了解JDK8默认垃圾收集器(附英文)
- Sql如何统计连续打卡天数
- d3 tip mysql_mysql
- mysql 5.7安装完密码是多少_关于mysql5.7.18的安装并修改初始密码的图文教程
- 第23章:MongoDB-聚合操作--聚合命令
- 学用 ASP.Net 之 System.Collections.Specialized.StringDictionary 类
- webssh的安装与使用
- CCF CSP 201903-1 小中大(C语言100分)[序列处理]
- 怎么下载网页在线视频
- SDOI 2014 数表 题解
- 研究:信仰能帮助人坦然面对挫折
- 行业分析-全球与中国船用废气解决方案市场现状及未来发展趋势
- mysql生成类似qq号_【mysql】类似QQ的好友关系表是怎么设计的?
- cad.net 依照旧样条曲线数据生成一条新样条曲线的代码段. spline生成
- 蓄电池基础知识安培小时AH和放电速率HR
- NOIP 2015 蒟蒻做题记录
- idea复制项目并使用技巧
热门文章
- linux 卸载软件_Linux学习总结--初学者必看指南
- 拓端tecdat|R语言用神经网络改进Nelson-Siegel模型拟合收益率曲线分析
- 【大数据部落】用R语言挖掘Twitter数据
- 带动量的随机梯度下降法_梯度下降法(SGD)原理解析及其改进优化算法
- 如何访问服务器表中信息,如何在 RADIUS 服务器的拨号接口上应用访问列表
- java接口自动化框架_java接口自动化测试框架及断言详解
- xgboost4j jar包下载
- caffe绘制训练过程的loss和accuracy曲线
- python LDA实践入门学习
- java制作大富翁游戏_JAVA大富翁游戏的设计+流程图+总结体设计图-论文.doc