1998 ACM NE Regionals
Each of five opaque spinning wheels has one or more wedges cut out of its edges. These wedges must be aligned quickly and correctly. Each wheel also has an alignment mark (at 0 degrees) so that the wheels can all be started in a known position. Wheels rotate in the `plus degrees' direction, so that shortly after they start, they pass through 1 degree, 2 degrees, etc. (though probably not at the same time).
This is an integer problem. Wheels are never actually at 1.5 degrees or 23.51234123 degrees. For example, the wheels are considered to move instantaneously from 20 to 25 degrees during a single second or even from 30 to 40 degrees if the wheel is spinning quickly.
All angles in this problem are presumed to be integers in the range 0 <= angle <= 359. The angle of 0 degrees follows the angle of 359 degrees. Each wheel rotates at a certain integer number of degrees per second, 1 <= speed <= 180.
Wedges for each wheel are specified by an integer start angle and integer angle size (or `extent'), both specified in degrees. Wedges in the test data will be separated by at least one degree. The 'extent' also includes the original "degree" of the wedge, so '0 180' means degrees 0..180 inclusive -- one more than most would imagine.
At the start, which is time 0, all the wheels' alignment marks line up. Your program must determine the earliest time (integer seconds) at or after the start that some wedge on each wheel will align with the wedges on the other wheel so that a light beam can pass through openings on all five wedges. The wedges can align at any part of the rotation.
PROGRAM NAME: spin
INPUT FORMAT
Each of five input lines describes a wheel.
The first integer on an input line is the wheel's rotation speed. The next integer is the number of wedges, 1 <= W <= 5. The next W pairs of integers tell each wedge's start angle and extent.
SAMPLE INPUT (file spin.in)
30 1 0 120 50 1 150 90 60 1 60 90 70 1 180 180 90 1 180 60
OUTPUT FORMAT
A single line with a single integer that is the first time the wedges align so a light beam can pass through them. Print `none' (lower case, no quotes) if the wedges will never align properly.
SAMPLE OUTPUT (file spin.out)
9
题意:
给出 5 个轮子的角速度 v,还有缺口个数 N 。后隔出个 N 对缺口的起始位置和长度。同一时间向前滚动,问哪一秒钟能同时穿过所有的轮子。
思路:
暴力。直接搜索 0 ~ 359 秒内的转动情况,同时标记好每一度数有几个轮子能被穿过,如果存在某一度数的轮子数为 5 ,说明这一秒中能被穿过,输出这个时间即可。如果 360 内都不能达到,则说明是 none。原以为会有公式,但是数据只有 5 个轮子,且缺口数最多也只有 5 ,所以直接暴力即可。
AC:
/* ID:sum-g1 LANG:C++ PROG:spin */ #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> using namespace std; typedef struct { int speed, num; int angle[10], len[10]; } node; node no[10]; int ans[365]; bool check() { for (int i = 0; i < 360; ++i) if (ans[i] == 5) return true; return false; } void solve () { for (int t = 0; t <= 359; ++t) { memset(ans, 0, sizeof(ans)); for (int i = 1; i <= 5; ++i) { for (int j = 1; j <= no[i].num; ++j) { int from = no[i].angle[j] + t * no[i].speed; for (int tt = from; tt <= from + no[i].len[j]; ++tt) ++ans[tt % 360]; } } if(check()) { printf("%d\n", t); return; } } printf("none\n"); } int main() { freopen("spin.in","r",stdin); freopen("spin.out","w",stdout); for (int i = 1; i <= 5; ++i) { scanf("%d%d", &no[i].speed, &no[i].num); for (int j = 1; j <= no[i].num; ++j) { scanf("%d%d", &no[i].angle[j], &no[i].len[j]); } } solve(); return 0; }
相关推荐
前端项目-css-spinning-spinners,零元素加载微调器的集合,仅由CSS设置动画
A spinning 3D cube with a choice of rendering modes. Runs over 60fps (on my 400Mhz PC) and it’s all done without DirectX or OpenGL!
平移变换平移法(cycle_spinning)消除gibbs效应
压缩感知_用平移变换平移法(cycle_spinning)消除gibbs效应
NULL 博文链接:https://as3.iteye.com/blog/972921
ANOTHER SPINNING TOP EXAMPLE
Pore formation of Polyurethane-based hollow fiber membrane prepared by melt-spinning,胡晓宇,肖长发,A novel pore formation process consisting of drawing, water cooking and secondary drawing was used...
为了提高图像去噪效果,提出了基于Contourlet域HMT模型的Cycle Spinning去噪方法。首先将待去噪图像进行循环平移,使用Contourlet域HMT模型对平移后的图像进行降噪处理,然后将降噪后的图像进行循环反平移,最后将...
We study optomechanically induced transparency in a spinning microresonator. We find that in the presence of rotation-induced Sagnac frequency shift, both the transmission rate and the group delay of ...
DeepRL模型 来自OpenAI的SpinningUp系列的DeepRL模型的自定义PyTorch实现。 复杂程度 香草政策梯度 信任区域政策优化 近端政策优化 深度确定性策略梯度 双延迟DDPG(4。) 软演员评论
睡觉与旋转 旋转或几乎总是被描述为一件坏事。 为什么要浪费整个CPU内核而实际上什么也不做呢? 为什么不让操作系统让线程进入睡眠状态并在准备好工作时将其唤醒? 不幸的是,“唤醒”线程需要一些时间。...
欢迎使用Deep RL中的Spinning Up! 这是OpenAI制作的教育资源,可让您更轻松地学习深度强化学习(deep RL)。 对于不熟悉的人:(RL)是一种机器学习方法,用于教坐席如何通过反复试验来解决任务。 深度RL是指RL与...
openai 推荐强化学习论文合集 https://spinningup.openai.com/en/latest/spinningup/keypapers.html#scaling-rl
Spinning_Circles_Fourier_Visualization_Example
超细电纺聚酰亚胺纤维的制备,王小昂,杨颖,直径小于100nm聚酰亚胺纤维有着十分广阔的应用前景。本文通过静电纺丝技术制备了均匀的聚酰亚胺纤维薄膜。研究了电纺溶液的表面张�
旋转的人行道Spinning Walks是协作的多媒体作品。
Decoupling Control of Micromachined Spinning-Rotor Gyroscope with Electrostatic Suspension
Can be used in 'value mode' or 'spinning mode'. Nice transitions between spinning and value. Can be used as a loading indicator and to show progress or values in a circular manner. In seek mode, it ...
Narrow-band radar imaging for off-grid spinning targets via compressed sensing
JavaScript是一门非常流行的编程语言,许多开发者... car.wheels = ; car.hubcaps = 'spinning'; car.age = ; 下面的写法能够达到同样的效果: var car = { colour:'red', wheels:, hubcaps:'spinning',