URAL 1327. Fuses
来源:互联网 发布:js调用as3方法 编辑:程序博客网 时间:2024/06/03 23:49
1327. Fuses
Time limit: 1.0 second
Memory limit: 64 MB
Memory limit: 64 MB
"Janus Poluektovich (I don't remember anymore whether -A or -U) used the machine only once. He brought with him a small semitransparent box, which he connected to the Aldan. In approximately ten seconds of operation with this device, all the circuit breakers blew, and Janus Poluektovich apologized, took his box, and departed."
Sasha Privalov, a young programmer working in the SRITS (Scientific Research Institute for Thaumaturgy and Spellcraft), finds his job rather enjoyable. Indeed, he is the only programmer of such a wonderful machine as Aldan-3 - that's a refreshing shift from a dull job in Leningrad. There is just a single problem, and the problem's name is Janus Poluektovich.
On Privalov's first workday, Janus burdened Aldan with the task of four-dimensional convolution in the conjuration space. Aldan worked for a while, flashing its lights and rewinding tapes, then a fuse blew and the machine shut down. Well, replacing fuses is something even a programmer can do. But Janus is rather absent-minded, and he, being lost in thoughts about his convolution problem, forgot about the weak fuse next day. So, on a third day Janus launched his program again, blowing another fuse. The fourth day went calmly, but on a fifth day one more fuse had to be replaced. And Janus is still not going to give up…
Nevertheless, these accidents don't bother Sasha, as long as he has enough spare fuses.
Your task is to help Sasha in making the requisition for spare parts. The requsition is made for a specific period - from the A-th workday to the B-th workday inclusive. You should calculate, how many fuses Janus is going to blow with his programs in the specified period of time.
Input
The first line contains an integer A. The second line contains an integer B. 1 ≤ A ≤ B ≤ 10000.
Output
The output should contain one number - the amount of fuses that will be blown by Janus in the interval from day A until day B.
Samples
15
3
100200
50
题意:第奇数天会换一个,偶数天不变。问从A天到B天(包括A, B)换了多少个。
解析:用(n + 1)/2算出到n天为止一共换了多少,同样算出m的个数,然后直接减。但是当n为奇数的时候,当天是要换的,所以要再加上第n天的那个!
AC代码:
#include <cstdio>int main(){ int n, m, ans; while(scanf("%d%d", &n, &m)==2){ ans = (m + 1)/2 - (n + 1)/2; if(n & 1) ans ++; //加上第n天换的那个 printf("%d\n", ans); } return 0;}
0 0
- URAL 1327. Fuses
- Timus 1327. Fuses
- Blowing Fuses
- Blowing Fuses
- Blowing Fuses
- fjnu 1685 Blowing Fuses
- zoj 1195 Blowing Fuses
- poj 1484 Blowing Fuses
- 1484 Blowing Fuses
- ZOJ1195 Blowing Fuses
- 661 - Blowing Fuses
- ZOJ 1195 Blowing Fuses
- poj1484 Blowing Fuses
- poj 1484 Blowing Fuses
- poj 1484Blowing Fuses
- poj 1484 Blowing Fuses
- UVa 661 - Blowing Fuses
- URAL
- OGG-01496 OGG-01031
- Firefox里input框中莫名出现文字
- 使用Spring的SimpleJdbcTemplate完成DAO操作
- 047-q1
- 机器学习(非传统统计方法如回归)到底在量化金融里哪些方面有应用?
- URAL 1327. Fuses
- 设置html页面不让浏览器缓存的方法
- @SuppressWarnings 注解详解
- LDAP error Code 及解决方法
- Python写自动化之SVN更新
- OpenCV.2.Computer.Vision.Application.Programming.Cookbook--Accessing pixel values
- java时间戳
- PostMessage,SendMessage,GetMessage,PeekMessage,TranslateMessage,DispatchMessage的用法集合
- Ubuntu下玩转VI--在命令行下编辑文件