As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.
You prefer flying from Seattle to San Francisco than in the other direction, because it‘s warmer in San Francisco. You are so busy that you don‘t remember the number of flights you have made in either direction. However, for each of the last n days you know whether you were in San Francisco office or in Seattle office. You always fly at nights, so you never were at both offices on the same day. Given this information, determine if you flew more times from Seattle to San Francisco during the last n days, or not.
Input
The first line of input contains single integer n (2?≤?n?≤?100) — the number of days.
The second line contains a string of length n consisting of only capital ‘S‘ and ‘F‘ letters. If the i-th letter is ‘S‘, then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given in chronological order, i.e. today is the last day in this sequence.
Output
Print "YES" if you flew more times from Seattle to San Francisco, and "NO" otherwise.
You can print each letter in any case (upper or lower).
Examples
input
4 FSSF
output
NO
input
2 SF
output
YES
input
10 FFFFFFFFFF
output
NO
input
10 SSFFSFFSFF
output
YES
Note
In the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is "NO".
In the second example you just flew from Seattle to San Francisco, so the answer is "YES".
In the third example you stayed the whole period in San Francisco, so the answer is "NO".
In the fourth example if you replace ‘S‘ with ones, and ‘F‘ with zeros, you‘ll get the first few digits of π in binary representation. Not very useful information though.
其实只要首是S,末尾是F就可以啦
#include <bits/stdc++.h>
usingnamespace std;
int main()
{
int n;
cin>>n;
string c;
cin>>c;
if(c[0]==‘S‘&&c[n-1]==‘F‘) cout<<"YES";
else cout<<"NO";
return0;
}
B. Save the problem!
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We‘re going to give you the answer, and you need to print a test case that produces the given answer. The original problem is in the following paragraph.
People don‘t use cash as often as they used to. Having a credit card solves some of the hassles of cash, such as having to receive change when you can‘t form the exact amount of money needed to purchase an item. Typically cashiers will give you as few coins as possible in change, but they don‘t have to. For example, if your change is 30 cents, a cashier could give you a 5 cent piece and a 25 cent piece, or they could give you three 10 cent pieces, or ten 1 cent pieces, two 5 cent pieces, and one 10 cent piece. Altogether there are 18 different ways to make 30 cents using only 1 cent pieces, 5 cent pieces, 10 cent pieces, and 25 cent pieces. Two ways are considered different if they contain a different number of at least one type of coin. Given the denominations of the coins and an amount of change to be made, how many different ways are there to make change?
As we mentioned before, we lost all the test cases for this problem, so we‘re actually going to give you the number of ways, and want you to produce a test case for which the number of ways is the given number. There could be many ways to achieve this (we guarantee there‘s always at least one), so you can print any, as long as it meets the constraints described below.
Input
Input will consist of a single integer A(1?≤?A?≤?105), the desired number of ways.
Output
In the first line print integers N and M(1?≤?N?≤?106,?1?≤?M?≤?10), the amount of change to be made, and the number of denominations, respectively.
Then print M integers D1,?D2,?...,?DM(1?≤?Di?≤?106), the denominations of the coins. All denominations must be distinct: for any i?≠?j we must have Di?≠?Dj.
If there are multiple tests, print any of them. You can print denominations in atbitrary order.
Examples
input
18
output
30 4 1 5 10 25
input
3
output
20 2 5 2
input
314
output
183 4 6 5 2 139
这个我真的没有什么思路
这个是题解的思路,奶一波
#include <bits/stdc++.h>
usingnamespace std;
int main()
{
int n;
cin>>n;
if(n==1)
{
cout<<1<<""<<1<<endl;
cout<<1;
return0;
}
int z=2*(n-1);
cout<<z<<""<<2<<endl;
cout<<1<<""<<2<<endl;
return0;
}