URAL 1617. Flat Spots(数学)

编程入门 行业动态 更新时间:2024-10-07 12:20:01

URAL 1617. Flat Spots(<a href=https://www.elefans.com/category/jswz/34/1770441.html style=数学)"/>

URAL 1617. Flat Spots(数学)

题目链接:.aspx?space=1&num=1612


1617. Flat Spots

Time limit: 0.5 second
Memory limit: 64 MB
Yekaterinburg has an extensive network of tram routes. Trams of more than ten routes go along some streets. It is clear that rails wear out quickly because of such a load. Rails near tram stops sometimes are wavy. Many citizens hold the city authorities responsible for such a poor state of tram railways: repair works are carried out rarely, and even if rails are replaced, it is only by cheapest ones—made of low-grade metal and with wooden ties. However, not only authorities are guilty of this situation. Some tram drivers are fans of fast driving, and they damage both rails and their trams. If a tram accelerates to a high speed, say 80 kilometers per hour, and then brakes sharply before a stop, it goes some distance skidding. This leads not only to rail spoilage, but also to wearing out wheels at the places where they touch rails. Flat spots emerge on the wheels, which cause pounding of the wheels, rattle of the car, and further rail spoilage. The administration of the tram depot decided to improve the situation by servicing all trams that have wheels with flat spots. To remove flat spots, wheels will be turned on a special lathe. Wheels from the same pair will be decreased to equal size, but wheels from different pairs may become different in size. To equip a car with wheels, repairmen must choose four wheel pairs with equal wheel diameters. Repairmen have finished turning all wheels. Some of them have become so small that they can't be used anymore. Such wheels will be sent for remelting. Instead of them, a stock of wheel pairs left from written-off cars can be used. Repairmen have measured all wheel pairs that can be mounted to cars, and now they need to know how many cars can be equipped.

Input

The first line contains the number  n of available wheel pairs (1 ≤  n ≤ 150). In the following  nlines, diameters of wheels in millimeters are given (they are integers in the range from 600 to 700).

Output

Output the number of cars that can be equipped with wheels using the given set of wheel pairs.

Sample

inputoutput
9
689
690
690
689
689
690
689
688
688
1


代码如下:

#include <cstdio>
#include <cmath>
#include <cstring>
int main()
{int n;int num[1000];while(~scanf("%d",&n)){int tt;memset(num, 0,sizeof(num));for(int i = 0; i < n; i++){scanf("%d",&tt);num[tt]++;}int ans = 0;for(int i = 600;  i <= 700; i++){ans+=num[i]/4;}printf("%d\n",ans);}return 0;
}


更多推荐

URAL 1617. Flat Spots(数学)

本文发布于:2024-02-13 12:45:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1758778.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数学   URAL   Spots   Flat

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!