CodeForces 321 A - Ciel and Robot】的更多相关文章

[题目链接]:click here~~ [题目大意]:一个robot 机器人 .能够依据给定的指令行动,给你四种指令,robot初始位置是(0,0).指令一出.robot会反复行动,推断是否能在无限行动的情况下经过点(n,m). [解题思路]事实上细致模拟一下,能够发现是有周期的.推断就可以,见代码吧~~ 代码: #include <iostream> #include <algorithm> #include <bits/stdc++.h> using namespa…
C. Ciel and Robot time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fox Ciel has a robot on a 2D plane. Initially it is located in (0, 0). Fox Ciel code a command to it. The command was repre…
题目链接:http://codeforces.com/problemset/problem/321/A 题意:在一个二维平面中,開始时在(0,0)点,目标点是(a.b),问能不能通过反复操作题目中的指令,从原点移动到目标点. 分析:如果一次完毕全部的命令后.移动到了(xx,yy),而且从(Xi.Yi)反复操作k次指令到达目标点.则能够列出方程 Xi + k * xx = a && Yi + k * yy = b.然后解出k.推断k是否大于等于0就可以. #include <cstdi…
唔...这题是数学题. 比赛时做出来,但题意理解错了,以为只要判断那点是不是在线上就行了,发现过不了样例就没提交. 思路:记录每一步的偏移,假设那点是在路径上的某步,然后回推出那一个周期的第一步,判断是不是在线上就行了. 本来用斜率做,没考虑斜率不存在的情况. 重新写了一遍,过了前十个样例.但是在追加的-1 -1 UR卡住了. 三鲜大神说: kx + b = y,判断整除就可以了.(orz) 于是想了一下,开始考虑整除,写了个判断的函数来判断就行了.(蒻菜只能写出又长又臭的判断) 代码: #in…
题目链接:http://codeforces.com/problemset/problem/752/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He…
Fox Ciel is playing a card game with her friend Jiro. Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards…
A题: 链接:http://codeforces.com/contest/580/problem/A dp,最长连续不上升子序列 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> using namespace std; ; int a[maxn],dp[maxn]; in…
294D - Shaass and Painter Robot 思路: 可以用数学归纳法证明一个结论:整个棋盘黑白相间当且仅当边缘黑白相间. 分奇偶讨论又可得出边缘黑色格个数为n+m-2 这样就可以暴力模拟. 数组开不下保存边缘块有没有被访问,可以用map. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,…
C. Vasya and Robot time limit per test: 1 secondmemory limit per test: 256 megabytesinput: standard inputoutput: standard output Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0,0)(0,0)(0,0). Robot can…
水题 #include<cstdio> #include<cstring> #include<cmath> #include<stack> #include<vector> #include<string> #include<iostream> #include<algorithm> using namespace std; int sx,sy; int ex,ey; int main() { scanf(&q…