首页 > 代码库 > Codeforce 835A - Key races
Codeforce 835A - Key races
Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2 milliseconds.
If connection ping (delay) is t milliseconds, the competition passes for a participant as follows:
- Exactly after t milliseconds after the start of the competition the participant receives the text to be entered.
- Right after that he starts to type it.
- Exactly t milliseconds after he ends typing all the text, the site receives information about it.
The winner is the participant whose information on the success comes earlier. If the information comes from both participants at the same time, it is considered that there is a draw.
Given the length of the text and the information about participants, determine the result of the game.
The first line contains five integers s, v1, v2, t1, t2 (1 ≤ s, v1, v2, t1, t2 ≤ 1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and the ping of the second participant.
If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship".
5 1 2 1 2
First
3 3 1 1 1
Second
4 5 3 1 5
Friendship
In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, the second wins.
In the third example, information on the success of the first participant comes in 22 milliseconds, of the second participant — in 22 milliseconds. So, it is be a draw.
题解:可以说是很水了
1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <vector> 6 #include <cstdlib> 7 #include <iomanip> 8 #include <cmath> 9 #include <ctime>10 #include <map>11 #include <set>12 using namespace std;13 #define lowbit(x) (x&(-x))14 #define max(x,y) (x>y?x:y)15 #define min(x,y) (x<y?x:y)16 #define MAX 10000000000000000017 #define MOD 100000000718 #define pi acos(-1.0)19 #define ei exp(1)20 #define PI 3.14159265358979323846221 #define INF 0x3f3f3f3f3f22 #define mem(a) (memset(a,0,sizeof(a)))23 typedef long long ll;24 ll gcd(ll a,ll b){25 return b?gcd(b,a%b):a;26 }27 const int N=205;28 const int mod=1e9+7;29 30 int main()31 {32 std::ios::sync_with_stdio(false);33 int s,v1,v2,t1,t2;34 cin>>s>>v1>>v2>>t1>>t2;35 int s1=s*v1+2*t1;36 int s2=s*v2+2*t2;37 if(s1<s2) cout<<"First"<<endl;38 else if(s1==s2) cout<<"Friendship"<<endl;39 else cout<<"Second"<<endl;40 return 0;41 }
Codeforce 835A - Key races