AtCoder Beginner Contest 158

Posted zdragon1104

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AtCoder Beginner Contest 158相关的知识,希望对你有一定的参考价值。

传送门

A - Station and Bus

技术图片
#include <bits/stdc++.h>
using namespace std;
char s[5];
int main() {
    //freopen("in.txt","r",stdin);
    scanf("%s",s);
    int a=0,b=0;
    for(int i=0;s[i];i++) {
        if(s[i]==A) a++;
        else b++;
    }
    printf("%s
",a&&b?"Yes":"No");
    return 0;
}
A.cpp

B - Count Balls

技术图片
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    //freopen("in.txt","r",stdin);
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    printf("%lld
",n/(a+b)*a+min(n%(a+b),a));
    return 0;
}
B.cpp

C - Tax Increase

题意:找到最小的正整数x,满足$left lfloor x*0.08 ight floor = A$并且$left lfloor x*0.1 ight floor = B$,若不存在,输出-1。

数据范围:1<=A<=B<=100。

题解:暴力枚举x判断即可,至少要枚举到1000。

技术图片
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    //freopen("in.txt","r",stdin);
    int a,b;
    scanf("%d%d",&a,&b);
    bool f=false;
    for(int i=1;i<=1500;i++) {
        if(i*8/100==a&&i/10==b) {
            printf("%d
",i);
            f=true;
            break;
        }
    }
    if(!f) printf("-1
");
    return 0;
}
C.cpp

D - String Formation

 

以上是关于AtCoder Beginner Contest 158的主要内容,如果未能解决你的问题,请参考以下文章