Codeforces Round #434

CF858A k-rounding(数论)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,k;
inline int do2(int x){
    int res=0;
    while(x&&x%2==0) x/=2,res++;
    return res;
}
inline int do5(int x){
    int res=0;
    while(x&&x%5==0) x/=5,res++;
    return res;
}
int main(){
    n=read();k=read();
    int a=do2(n),b=do5(n);
    if(a>=k&&b>=k) printf("%d\n",n);
    else{
        ll ans=n;
        while(a<k) ans*=2,++a;
        while(b<k) ans*=5,++b;
        printf("%I64d\n",ans);
    }
    return 0;
}

CF858B Which floor?(暴力)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 200010
#define pa pair<int,int>
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m,ans=0;
pa a[N];
inline bool jud(int x){
    for(int i=1;i<=m;++i)
        if((a[i].first-1)/x+1!=a[i].second) return 0;
    return 1;
}
int main(){
//  freopen("a.in","r",stdin);
    n=read();m=read();
    for(int i=1;i<=m;++i){
        a[i].first=read();a[i].second=read();
    }
    for(int x=1;x<=100;++x)
        if(jud(x)){
            if(ans&&ans!=(n-1)/x+1){puts("-1");return 0;}
            else ans=(n-1)/x+1;
        }
    printf("%d\n",ans);
    return 0;
}

CF858C Did you mean…(贪心)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 3110
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n;
char s[N];
bool f[N];
int main(){
//  freopen("a.in","r",stdin);
    scanf("%s",s+1);n=strlen(s+1);
    for(int i=1;i<=n;++i)
        if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u') f[i]=0;
        else f[i]=1;
    for(int i=1;i<=n;++i){
        if(!f[i]||!f[i+1]||!f[i+2]||(s[i]==s[i+1]&&s[i+1]==s[i+2])) putchar(s[i]);
        else printf("%c%c ",s[i],s[i+1]),i++;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值