Codeforces Round #434

http://codeforces.com/contest/861
三道水题,一道字典树(又是没看题意直接百度)。。
水题还有一道开始没看懂。。。
A
求m的 k-round数。
就是 后面有k个0的m的最小倍数。。
我是用暴力算的。
先算 小于100000..(k个0) 的最大的m的倍数,然后不够再加。

// 702ms...
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m,n,ss;
bool solve(ll s){
    if(s%ss) return true;
    return false;
}
int main()
{   while(~scanf("%lld%lld",&m,&n)){
    ss=1;
    //cout<<m<<endl;
    for(int i=1;i<=n;i++)
        ss*=10;
      ll t=ss/m;
       ll tt;
       tt=m*(t);
       if(!tt)
        tt+=m;
      while(solve(tt)){
          tt+=m;
      }
    printf("%lld\n",tt);
}
    return 0;
}

直接求 lcm岂不美哉。。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
    if(!b) return a;
    return gcd(b,a%b);
}
ll m,k;
int main(){
    while(~scanf("%lld%lld",&m,&k)){
          ll ans=1;
          for(int i=1;i<=k;i++)
            ans*=10;
          printf("%lld\n",ans*m/gcd(ans,m));
    }
}

C 单词分割。
题意:两个条件。
1 三个浊音 连着并且 浊音种类要求至少为2,用最少的空格取消掉 这种存在。
(三个浊音连起来不算。)
开始写了一遍写错了,应该判断条件,如果当前值满足条件,就再当前值后面放空格。否则不要放。
(开始写的是 判断当前值,然后当前值如果满足,再他前面空格)

#include <bits/stdc++.h>
using namespace std;
string s;
bool mp[30];
bool solve(char s){
   if(s!='a'&&s!='e'&&s!='i'&&s!='o'&&s!='u')
     return true;
   return false;
}
int main()
{   ios::sync_with_stdio(false);
    while(cin>>s){
    int len=0;
    int siz=0;
    int kk=0;
    for(int i=0;i<s.length();i++){
        if(solve(s[i])&&len>=2&&((kk>=2)||(kk>=1&&!mp[s[i]-'a']))){
            printf(" %c",s[i]);
            memset(mp,false,sizeof(mp));
            kk=0;
            len=0;
            }
        else
            printf("%c",s[i]);
            if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
            {   kk=0;
                len=0;
                memset(mp,false,sizeof(mp));
            }
            else{
                len++;//mp[s[i]]=true;
                if(!mp[s[i]-'a'])
                 {  mp[s[i]-'a']=true;
                    kk++;
                 }
            }
    }
    }
    return 0;
}

b和d明天补qwq

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值