Codeforces Round #437

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是优先队列

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值