最终成绩: 300/600
第一题
The Speed Limit
All submissions for this problem are available.Chef is travelling to the nearest cricket stadium to watch his favourite team play. Unfortunately for him, he is running late. The road to the stadium has a speed limit L km/h. If Chef is D kms away from the stadium, find whether he can reach the stadium in H hours, if he cannot travel faster than the speed limit.
Input:
First line of input contains the number of test cases T. Then the test cases follow.
Each test case consists of three space separated integers L, D and H denoting the speed limit in km/h, the distance and the number of hours in which Chef has to reach the stadium.
Output:
For each test case, output in a single line, the word ‘Yes’ if Chef can reach on time, and the word ‘No’ if he cannot.
Constraints:
1≤T≤5
1≤L≤300
1≤D≤7000
1≤H≤24
Sample Input:
2
100 250 2
72 123 3
Sample Output:
No
Yes
题目大意:
已知时间,速度,求是否能赶上棒球比赛。
题目解析:
超级签到题。
具体代码:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int t,l,d,h;
cin>>t;
while(t--){
cin>>l>>d>>h;
if(l*h>=d)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}
第二题
The Prime Count
All submissions for this problem are available.Consider a generalized form of Fibonacci sequence where the first two terms are defined arbitrarily. Your task is to find total number of primes in the first 20 terms of the sequence, given the first two terms F1 and F2
Input:
First line of input contains the number of test cases T. Then the test cases follow.
Each test case consists of two space separated integers F1 and F2, which are the first two terms of the sequence.
Output:
For each test case, output in a single line the number of primes in the first 20 terms of the sequence.
Constraints:
1≤T≤2∗105
2≤F1,F2≤100
Sample Input:
1
100 37
Sample Output:
4
题目大意:
给出斐波那契数列的前两项,求前20项中的素数个数。
题目解析:
这题要判断的数很多,要用线性筛素数。
具体代码:
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
const int N = 700000;<