Codeforces Round #140 (Div. 2)
来源:互联网 发布:淘宝开店注册在哪里 编辑:程序博客网 时间:2024/05/17 19:21
A. Where do I Turn?
#include <iostream>using namespace std;struct point{ long long x,y;}p[3];long long chaji(point a,point b,point c){ return (c.x-a.x)*(b.y-a.y)-(b.x-a.x)*(c.y-a.y);}int main(){ int i; for(i=0;i<3;i++) cin>>p[i].x>>p[i].y; if((p[2].y-p[1].y)*(p[1].x-p[0].x)==(p[1].y-p[0].y)*(p[2].x-p[1].x)) cout<<"TOWARDS"<<endl; else if(chaji(p[2],p[1],p[0])>0) cout<<"LEFT"<<endl; else cout<<"RIGHT"<<endl; return 0;}
B. Effective Approach
#include <iostream>using namespace std;int main(){ long long n,m,x,i,ans1,ans2; int data[100005],inp[100005]; cin>>n; for(i=1;i<=n;i++) { cin>>data[i];inp[data[i]]=i; } cin>>m; for(i=1;i<=m;i++) { cin>>x; ans1+=inp[x]; ans2+=(n-inp[x]+1); } cout<<ans1<<" "<<ans2<<endl; return 0;}
0 0
- Codeforces Round #140 (Div. 2)
- Codeforces Round #140 (Div. 2)
- Codeforces Round #140 (Div. 1)
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- Codeforces Round #121 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #125 (Div. 2)
- Codeforces Round #124 (Div. 2)
- Codeforces Round #139 (Div. 2)
- Codeforces Round #147 (Div. 2) B. Young Table
- 解决get传值乱码问题
- 第6周作业1-闰年之循环判断LeapYearFor
- leetcode: Remove Element
- Codeforces Round #140 (Div. 2)
- 几种文献管理软件及其相关介绍
- 10个在随机出现在面试中的Linux问题及答案
- SQL DateTime 相关函数
- 强制文件下载而不是在浏览器里打开显示
- GDB如何从Coredump文件恢复动态库信息
- 修复windows 7 输入法
- Android中Bitmap,byte[],Drawable相互转化
- WebService笔记(三):SOAP