Codeforces Round 190 div.2 322C 321A Ciel and Robot
唔。。。这题是数学题。
比赛时做出来,但题意理解错了,以为只要判断那点是不是在线上就行了,发现过不了样例就没提交。
思路:记录每一步的偏移,假设那点是在路径上的某步,然后回推出那一个周期的第一步,判断是不是在线上就行了。
本来用斜率做,没考虑斜率不存在的情况。
重新写了一遍,过了前十个样例。但是在追加的-1 -1 UR卡住了。
三鲜大神说: kx + b = y,判断整除就可以了。(orz)
于是想了一下,开始考虑整除,写了个判断的函数来判断就行了。(蒻菜只能写出又长又臭的判断)
代码:
#include <cstdio>
#include <cstring>
int x = 0, y = 0, pos[101][2] = {0}; bool judge(int px, int py) {
if (x == 0 && y != 0)
if (px == 0 && py % y == 0 && py / y >= 0)
return true;
else
return false;
if (y == 0 && x != 0)
if (py == 0 && px % x == 0 && px / x >= 0)
return true;
else
return false;
if (x == 0 && y == 0)
if (px == 0 && py == 0)
return true;
else
return false;
if (x != 0 && y != 0)
if (py == px / x * y && px % x == 0 && px / x >= 0)
return true;
else
return false;
}//bool
int main() {
int a, b;
char op[101];
scanf("%d%d%s", &a, &b, op);
if (a == 0 && b == 0) {
printf("Yes\n");
return 0;
}
for (int i = 0; i < strlen(op); i++) {
switch (op[i]) {
case 'U': y++; break;
case 'D': y--; break;
case 'L': x--; break;
case 'R': x++; break;
}
pos[i][0] = x;
pos[i][1] = y;
}//for
for (int i = 0; i < strlen(op); i++)
if (judge(a - pos[i][0], b - pos[i][1])) {
printf("Yes\n");
return 0;
}//if
printf("No\n");
return 0;
}
以后要争取在比赛时做出C及后面的题目。。。
Codeforces Round 190 div.2 322C 321A Ciel and Robot的更多相关文章
- 树上的构造 树分治+树重心的性质 Codeforces Round #190 (Div. 2) E
http://codeforces.com/contest/322/problem/E E. Ciel the Commander time limit per test 1 second memor ...
- Codeforces Round #190 (Div. 1 + Div. 2)
A. Ciel and Dancing 模拟. B. Ciel and Flowers 混合类型的数量只能为0.1.2,否则3个可以分成各种类型各自合成. C. Ciel and Robot 考虑一组 ...
- Codeforces Round #190 (Div. 2) E. Ciel the Commander 点分治
E. Ciel the Commander Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest ...
- Codeforces Round #190 (Div. 2) B. Ciel and Flowers
链接:http://codeforces.com/contest/322/problem/B 这题做错了.没考虑周全. #include <cstdio> #include <cst ...
- Codeforces Round #190 DIV.2 A. Ciel and Dancing
#include <cstdio> #include <iostream> #include <vector> using namespace std; int m ...
- Codeforces Round #190 (Div. 2).D
一道贪心题. 可以分两种情况 1 .是没有把对面的牌全打败,那么只要用最大的可能去打攻击状态的牌. 2. 是将对面的牌全打败,那么只要保证打对面防守状态的花费最小,就可以保证最后的结果最大 两种情况下 ...
- Codeforces Round #190 (Div. 2) 水果俩水题
后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...
- [置顶] Codeforces Round #190 (Div. 2)(完全)
好久没有写博客了,一直找不到有意义的题可以写,这次也不算多么有意义,只是今天是比较空的一天,趁这个时候写一写. A. B. 有一点贪心,先把每个拿去3的倍数,余下0或1或2,然后三个一起拿. 对于以上 ...
- Codeforces Round #389 Div.2 C. Santa Claus and Robot
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
随机推荐
- VB IE 清除历史记录
VB删除Cookie,仅适用于IE7版本 IE7版本为我们提供了命令行删除Cookie,清除临时文件缓存,清除历史记录表单的方法,下面是详细的命令运行方式. '注:以下代码仅支持IE7. '清除Int ...
- mysql注册服务
http://www.2cto.com/database/201301/185456.html ____________________________________________________ ...
- 使用MySQL正则表达式查询
MySQL用WHERE子句对正则表达式提供了初步的支持,允许你指定用正则表达式过滤SELECT检索出的数据. REGEXP后所跟的东西作为正则表达式处理. 代码 SELECT prod_name FR ...
- Cannot retrieve metalink for repository: epel. Please verify its path and try again
今天在测试环境使用yum安装,遇到一个问题: Error: Cannot retrieve metalink for repository: epel. Please verify its path ...
- delphi 窗口最大化后控件的大小变化怎么设置
设置按钮的Anchors属性.可以通过此属性设置其边界是否随父类一起变化.默认akleft+aktop即左边界和上边界随窗口变化,也就是说如果窗口位置移动了,按钮将保持其left和top边界与窗口的距 ...
- 文件频繁IO能有多大的差别
测试文件写同样大小的文件,单次记录较小和单次记录较大能有多大的性能差别. 最终写入同样大小的文件,小记录需要写入10w次,大记录需要写入1w次,看下最终的性能报告
- DuiVision开发教程(17)-对话框
DuiVision的对话框类是CDlgBase. 代码中假设须要创建一个对话框,一般建议使用DuiSystem类中封装的若干对话框相关的函数来操作,包括创建对话框.删除对话框.依据对话框名获取对话框指 ...
- Codeforces Gym 100002 C "Cricket Field" 暴力
"Cricket Field" Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1000 ...
- delphi 动态建立WebBrower
//Delphi动态建立WebBrowerunit Main;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphi ...
- asp.net mvc控制器动作体返回ImageResult,可作验证码
public ActionResult Img() { // 获取博客园空间顶部的banner图片 WebRequest req = WebRequest.Create("http://sp ...