Codeforces Round #434

来源:互联网 发布:圆柱齿轮强度校核软件 编辑:程序博客网 时间:2024/05/22 10:51

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

原创粉丝点击