http://codeforces.com/contest/867
A
S和F表示俩城市。sf表示从s飞到f。
问是否从s到f 比f到s的次数更多。
模拟。
官方题解:直接判断第一位和最后一位就行。。我tm.
#include <bits/stdc++.h>
using namespace std;
string s;
int m;
int main()
{ cin>>m>>s;
int sum1=0;
int sum2=0;
for(int i=0;i<s.length()-1;i++){
if(s[i]=='S'&&s[i+1]=='F')
sum1++;
else if(s[i]=='F'&&s[i+1]=='S')
sum2++;
}
if(sum1>sum2&&sum1!=0)
puts("YES");
else
puts("NO");
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 101;
int n;
char s[N];
int main() {
scanf("%d %s", &n, s);
if(s[0] == 'S' && s[n-1] == 'F') puts("YES");
else puts("NO");
return 0;
}
B 构造。
没想到,太强了。
输入一个x
给定一个种类,要求你构造 m总数,n为硬币数。
要求 这些硬币(不限数量)构成m的数量为x。。
蜜汁规律。
我们发现 总和是(x-1)*2;
为啥呢 2硬币为 x-1 1 为0;
2硬币为x-2 1为2
…
2硬币为0,1为2(x-1).
。。
当为1时,是1.其他就是这个规律qwq
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
scanf("%d",&n);
if(n==1) printf("1 1\n1\n");
else
printf("%d 2\n1 2\n",(n-1)*2);
}
C是贪心,E是优先队列