首页 > 其他 > 详细

URAL 1617. Flat Spots(数学啊 )

时间:2015-03-20 23:52:04      阅读:535      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.timus.ru/problem.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

input output
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(数学啊 )

原文:http://blog.csdn.net/u012860063/article/details/44498187

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!