博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 3104 Combination Lock(数学题)
阅读量:5876 次
发布时间:2019-06-19

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

题目链接:

pid=3104

Problem Description
A combination lock consists of a circular dial, which can be turned (clockwise or counterclockwise) and is embedded into the "fixed" part of the lock. The dial has N evenly spaced "ticks". The ticks are numbered from 0 to N - 1 , increasing in the clockwise direction. The fixed part of the lock has a "mark" which always "points to" a particular tick on the dial. Of course, the mark points to different ticks as the dial is turned.
The lock comes with three code numbers T1 , T2 , T3 . These are non-negative integers and each of them is less than N . No two of the three are the same.
The lock is opened in three stages of operations:
1. Turn the dial clockwise exactly two full revolutions, and continue to turn it clockwise until the mark points to tick T1 .
2. Turn the dial one full revolution counterclockwise and continue to turn it counterclockwise until the mark points to tick T2 .
3. Turn the dial clockwise until the mark points to tick T3 . The lock should now open.
You must find the maximum possible number of ticks the dial must be turned in order to open the lock. The number of ticks turned is defined to be the sum of the ticks turned in the three stages outlined above, and is always positive regardless of direction.
 
Input
The input file consists of a number of test cases, one test case per line. Each line of the input file contains four integers: N , T1 , T2 , T3 , in this order, separated by blank spaces. The integer N is a multiple of 5, 25<=N<=100 . The numbers T1 , T2 and T3 satisfy the constraints stated under the description above. The input will be terminated by a line with N = T1 = T2 = T3 = 0 .
 
Output
For each test case, print the maximum possible number of ticks the dial must be turned in order to open the lock. Print each on its own line.
 
Sample Input
 
80 20 40 50 80 10 79 12 0 0 0 0
 
Sample Output
 
409 455
 
Source

题意:

转动表盘:

1、顺时针转动两圈后再转到T1。

2、逆时针转动一圈后再转到T2;

3、顺时针转动到T3。

问终于转了多少格;

PS:

顺时针转动表盘。相当于逆时针转动指针。

代码例如以下:

#include
int main(){ int n; int a1,a2,a3; int ans; while(~scanf("%d%d%d%d",&n,&a1,&a2,&a3)) { if(n==0 && a1==0 && a2==0 && a3==0) break; ans = 4*n-1; if(a2>a1) { ans+=a2-a1; } else { ans+=n+a2-a1; } if(a3

转载地址:http://pwkix.baihongyu.com/

你可能感兴趣的文章
Deis发布1.4版本,支持Microsoft Azure
查看>>
用Elm语言降低失败的风险
查看>>
荷兰商业银行使用精益领导力推行改进
查看>>
cisco 多生成树MST笔记
查看>>
FPGA设计——图像处理(锐化增强)
查看>>
LINUX REDHAT第十三单元练习题
查看>>
Play Framework
查看>>
集合转数组注意
查看>>
gng3使用方法,正确的路由器防火墙安全配置方式
查看>>
基于域名虚拟主机及主站迁移
查看>>
linux sed
查看>>
elk之elasticsearch 入门
查看>>
C++11 thread
查看>>
云:虚拟之上的管理平台
查看>>
石墨烯+新能源:光伏领域应用潜力巨大
查看>>
本节书摘来自华章出版社《 自动化测试最佳实践:来自全球的经典自动化测试案例解析 》一 2.2 测试中的软件...
查看>>
2022 年 AI 会发展成什么样子,IBM 做出了 5 大预测
查看>>
深入NLP———看中文分词如何影响你的生活点滴 | 硬创公开课
查看>>
老叶观点:MySQL开发规范之我见
查看>>
Silverlight 2 DispatcherTimer和通过XAML创建UI元素
查看>>