ACM: O: Assignments

ACM: O: Assignments

Description

    When Starfleet headquarters gets a request for an exploration expedition, they need to determine which ship from those currently docked in the docking bay to send. They decide to send whichever ship is currently able to make the expedition based on how much fuel is currently stored on the ship as well as how long it will take the ship to arrive at the expected destination. Due to the age and current maintenance of the ships, each ship travels at a different top speed and has a different fuel consumption rate. Each ship reaches its top speed instantaneously.

Input

Input begins with a line with one integer T (1 ≤ T ≤ 50) denoting the number of test cases. Each test case begins with a line with two space-separated integers N and D, where N (1 ≤ N ≤ 100) denotes the number of ships in the docking bay and D (1 ≤ D ≤ 106) denotes the distance in lightyears to the expedition site. Next follow N lines with three space-separated integers vi, fi, and ci, where vi (1 ≤ vi ≤ 1000) denotes the top speed of ship i in light-years per hour, fi (1 ≤ fi ≤ 1000) denotes the fuel on ship i in kilos of deuterium, and ci (1 ≤ ci ≤ 1000) denotes the fuel consumption of ship i in kilos of deuterium per hour.

Output

For each test case, print a single integer on its own line denoting the number of ships capable of reaching the expedition site. Be careful with integer division!

Sample Input

2
3 100
52 75 10
88 13 44
56 9 5
2 920368
950 950 1
943 976 1

Sample Output

2
1
注:題目雖然臭長臭長,但意思很簡單,只要用距離除以速度再乘以每小時消耗,和總燃料比較即可。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define LL long long
using namespace std;
int main()
{
    int T;
    int n,d;
    int v,f,c;
    cin>>T;
    while(T--)
    {
        int count=0;
        cin>>n>>d;
        for(int i=0;i<n;i++)
        {
            cin>>v>>f>>c;
            if((double)(d*c)/v<=f)
                count++;
        }
        cout<<count<<endl;
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章