唔。。。这题是数学题。

比赛时做出来,但题意理解错了,以为只要判断那点是不是在线上就行了,发现过不了样例就没提交。

思路:记录每一步的偏移,假设那点是在路径上的某步,然后回推出那一个周期的第一步,判断是不是在线上就行了。

本来用斜率做,没考虑斜率不存在的情况。

重新写了一遍,过了前十个样例。但是在追加的-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的更多相关文章

  1. 树上的构造 树分治+树重心的性质 Codeforces Round #190 (Div. 2) E

    http://codeforces.com/contest/322/problem/E E. Ciel the Commander time limit per test 1 second memor ...

  2. Codeforces Round #190 (Div. 1 + Div. 2)

    A. Ciel and Dancing 模拟. B. Ciel and Flowers 混合类型的数量只能为0.1.2,否则3个可以分成各种类型各自合成. C. Ciel and Robot 考虑一组 ...

  3. 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 ...

  4. Codeforces Round #190 (Div. 2) B. Ciel and Flowers

    链接:http://codeforces.com/contest/322/problem/B 这题做错了.没考虑周全. #include <cstdio> #include <cst ...

  5. Codeforces Round #190 DIV.2 A. Ciel and Dancing

    #include <cstdio> #include <iostream> #include <vector> using namespace std; int m ...

  6. Codeforces Round #190 (Div. 2).D

    一道贪心题. 可以分两种情况 1 .是没有把对面的牌全打败,那么只要用最大的可能去打攻击状态的牌. 2. 是将对面的牌全打败,那么只要保证打对面防守状态的花费最小,就可以保证最后的结果最大 两种情况下 ...

  7. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  8. [置顶] Codeforces Round #190 (Div. 2)(完全)

    好久没有写博客了,一直找不到有意义的题可以写,这次也不算多么有意义,只是今天是比较空的一天,趁这个时候写一写. A. B. 有一点贪心,先把每个拿去3的倍数,余下0或1或2,然后三个一起拿. 对于以上 ...

  9. 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 ...

随机推荐

  1. Shell统计报表表格生成

    基本需求 分析完数据后,一般需要将数据以附件的形式发送处理,这个已经在<>中有介绍,如何 用Python实现附件的发送. 但不是所有人都关心附件的内容,一般邮件中需要有些概要的信息,如附件 ...

  2. POI Excel导出样式设置

    HSSFSheet sheet = workbook.createSheet("sheetName");    //创建sheet sheet.setVerticallyCente ...

  3. Oracle DataGuard 物理Standby 搭建(上)

    物理standby database 环境搭建 Arch asysnc Oracle Dataguard host IP Oracle_sid DB_unique_name FAL_server FA ...

  4. java.io.File类

    java.io.File类 1.凡是与输入.输出相关的类.接口等都定义在java.io包下 2.File是一个类.能够有构造器创建其对象.此对象相应着一个文件(.txt .avi .doc .ppt ...

  5. JQuery Basic Features Quick Walkthrough

    1. Basic Selectors $('p')—Accesses all the paragraph elements in the HTML file $('div')—Accesses all ...

  6. TC SRM 664 div2 B BearPlaysDiv2 bfs

    BearPlaysDiv2 Problem Statement    Limak is a little bear who loves to play. Today he is playing by ...

  7. 飘逸的python - 编码杂症之在字符串前面加u

      有时候我们从其它地方接受的字符串经过艰难跋涉,它变了个样.比如收到的是'\u6253\u602a\u8005'而不是u'\u6253\u602a\u8005'. 明明肉眼看起来只需要加个u,但是怎 ...

  8. Java中Scanner的使用方法

      Scanner是SDK1.5新增的一个类,但是使用该类创建一个对象.Scanner reader=new Scanner(System.in); 然后reader对象调用下列方法(函数),读取用户 ...

  9. ListView删除选中的多项目

    //ListView删除选中的多项目function DeleteMultSelItems(ListView:TListView):Boolean;var  I: Integer;begin  Res ...

  10. MaterialViewPager

    https://github.com/florent37/MaterialViewPager