博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #239 (Div. 1) 解题报告
阅读量:6738 次
发布时间:2019-06-25

本文共 3014 字,大约阅读时间需要 10 分钟。

Problem A

题意:给你直角三角形的两条直角边问你能不能构造出这个三角形使其任意一条边都不和坐标轴平行。输出三点坐标

思路:固定直角的顶点为原点由于范围最大1000所以直接暴力枚举所有可能点,既满足勾股定理的点。然后逐个验证即可。

代码如下:

1 /**************************************************  2  * Author     : xiaohao Z  3  * Blog     : http://www.cnblogs.com/shu-xiaohao/  4  * Last modified : 2014-03-30 14:45  5  * Filename     : Codeforce_239_1_A.cpp  6  * Description     :   7  * ************************************************/  8   9 #include 
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 #include
19 #include
20 #define MP(a, b) make_pair(a, b) 21 #define PB(a) push_back(a) 22 23 using namespace std; 24 typedef long long ll; 25 typedef pair
pii; 26 typedef pair
puu; 27 typedef pair
pid; 28 typedef pair
pli; 29 typedef pair
pil; 30 31 const int INF = 0x3f3f3f3f; 32 const double eps = 1E-6; 33 const int LEN = 1010; 34 int xx[] = { 1, 1, -1,-1}; 35 int yy[] = { 1,-1, -1, 1}; 36 37 bool is(int a, int b, int c, int d){ 38 return (a*c + b*d == 0 ? true : false); 39 } 40 41 bool solve(pii a, pii b){ 42 int ax, ay, bx, by; 43 for(int i=0; i<4; i++){ 44 int j = (i+1)%4; 45 ax = a.first*xx[i]; 46 ay = a.second*yy[i]; 47 bx = b.first*xx[j]; 48 by = b.second*yy[j]; 49 if(is(ax, ay, bx, by) && bx!=ax && by!=ay){ 50 cout << "YES" << endl; 51 cout << "0 0" << endl; 52 cout << ax << ' ' << ay << endl; 53 cout << bx << ' ' << by << endl; 54 return true; 55 } 56 } 57 return false; 58 } 59 60 int main() 61 { 62 freopen("in.txt", "r", stdin); 63 64 int a, b, ans, ta, tb; 65 pii posa[LEN], posb[LEN]; 66 while(cin >> a >> b){ 67 ans = ta = tb = 0; 68 for(int i=1; i
View Code

Problem B

题意:有一排房间每个房间有两扇门,一扇通往i+1个房间,另一扇通往a[i]个房间,然后他每经过一个房间就做一个标记,只有偶数个标记时他才会走第一扇门。问你他要走多少单位时间。

思路:dp[i]表示到当前房间走到下一房间的花费。这样每次只要先回到a[i]然后再一个个走上来就行了。

代码如下:

1 /************************************************** 2  * Author     : xiaohao Z 3  * Blog     : http://www.cnblogs.com/shu-xiaohao/ 4  * Last modified : 2014-03-30 14:45 5  * Filename     : Codeforce_239_1_B.cpp 6  * Description     :  7  * ************************************************/ 8  9 #include 
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 #include
19 #include
20 #define MP(a, b) make_pair(a, b)21 #define PB(a) push_back(a)22 23 using namespace std;24 typedef long long ll;25 typedef pair
pii;26 typedef pair
puu;27 typedef pair
pid;28 typedef pair
pli;29 typedef pair
pil;30 31 const int INF = 0x3f3f3f3f;32 const double eps = 1E-6;33 const int MOD = 1000000007;34 const int LEN = 1001;35 int dp[LEN], n, a[LEN];36 37 void debug(){38 for(int i=0; i
> n){46 for(int i=0; i
> a[i];a[i]--;48 }49 int ans = 0;50 for(int i=0; i
View Code

 

转载于:https://www.cnblogs.com/shu-xiaohao/p/3634380.html

你可能感兴趣的文章
Ajax注册表单用户名实时验证
查看>>
centos: 建立git账户
查看>>
BZOJ2325[ZJOI2011]道馆之战——树链剖分+线段树
查看>>
MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作
查看>>
LAMP简单架构实验:Apache+NFS+MySQL
查看>>
ll命令
查看>>
邮件附件在线预览——HTML Filter
查看>>
PC桌面右下方QQ托盘图标
查看>>
jenkins执行启动java程序后,会杀掉程序的解决方法
查看>>
升值加薪的人中为什么么有你???
查看>>
Linux 之 iptables
查看>>
linux下的静态库和动态库分析
查看>>
zabbix自动报警邮件正文变成附件问题解决
查看>>
豆瓣阿北:用户价值大于产品体验,通过产品做运营
查看>>
我的友情链接
查看>>
利用clonezilla克隆、还原CentOS整个系统
查看>>
解决127.0.0.1 localhost 劫持问题
查看>>
winscp连接虚拟机Linux被拒绝的问题解决方案
查看>>
教程-Delphi设置功能表
查看>>
Java中的多线程,线程池
查看>>