码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)

时间:2017-10-02 23:48:07      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:mod   sync   using   cto   isp   define   type   http   splay   

A. k-rounding

题目意思:给两个数n和m,现在让你输出一个数ans,ans是n倍数且末尾要有m个0;

题目思路:我们知道一个数末尾0的个数和其质因数中2的数量和5的数量的最小值有关系,所以我们可以把n中的2和5的因子数量分别算出来,然后看一下是否都大于等于m,否则我们就把他们补成m个。然后再乘回去就结束了。

题目链接:http://codeforces.com/contest/861/problem/A

代码:

技术分享
 1 /* ***********************************************
 2 Author        :xiaowuga
 3 Created Time  :2017年10月02日 星期一 18时00分24秒
 4 File Name     :A.cpp
 5 ************************************************ */
 6 #include <bits/stdc++.h>
 7 #define mem(s,ch) memset(s,ch,sizeof(s))
 8 typedef long long LL; 
 9 #define inf 0x3f3f3f3f 
10 const long long N=1000000;
11 const long long mod=1e9+7;
12 using namespace std;
13 int main(){
14     ios::sync_with_stdio(false);cin.tie(0);
15     LL n,k;
16     cin>>n>>k;
17     LL c1=0,c2=0;    
18     LL t=n;
19     while(t%2==0){
20         c1++;
21         t/=2;
22     }
23     while(t%5==0){
24         c2++;
25         t/=5;
26     }
27     while(c1<k) c1++;
28     while(c2<k) c2++;
29     for(int i=0;i<c1;i++){
30         t*=2;
31     }
32     for(int i=0;i<c2;i++){
33         t*=5;
34     }
35     cout<<t<<endl;
36     return 0;
37 }
View Code

B. Which floor?

题目意思:小明住在一个每层楼都有相同数量房间的大楼里面,但是他忘记每层楼有多少个房间了。现在他只记得某些房间在几楼,现在让你根据小明的记忆,判断编号为n的房间在哪一楼是否可以确定。(房间的编号从1-n)从底层到高层;

题目思路:我们发现数据范围很小,这意味这我们可以暴力枚举每层有多少间房间,然后和小明的记忆进行比对,然后把符合小明记忆的数量存起来,然后最后判断他们指出编号为n的房间的楼层是否相同,如果不同就输出-1.

题目链接:http://codeforces.com/contest/861/problem/B

代码:

技术分享
 1 /* ***********************************************
 2 Author        :xiaowuga
 3 Created Time  :2017年10月02日 星期一 18时48分45秒
 4 File Name     :B.cpp
 5 ************************************************ */
 6 #include <bits/stdc++.h>
 7 #define mem(s,ch) memset(s,ch,sizeof(s))
 8 typedef long long LL; 
 9 #define inf 0x3f3f3f3f 
10 const long long N=1000000;
11 const long long mod=1e9+7;
12 using namespace std;
13 vector<pair<int,int> >q;
14 vector<int>p;
15 int main(){
16     ios::sync_with_stdio(false);cin.tie(0);
17     int n,k;
18     cin>>n>>k;
19     q.resize(k+1);
20     for(int i=0;i<k;i++) {
21         cin>>q[i].first>>q[i].second;
22     }
23     int ct=0;
24     int ans=0;
25     for(int i=1;i<=100;i++){
26         int cnt=0;
27         for(int j=0;j<k;j++){
28             int x=q[j].first,y=q[j].second;    
29             int l;
30             if(x%i==0) l=0;else l=1;
31             int z=x/i+l;
32             if(z==y) cnt++;
33             else break;
34         }
35         if(cnt==k){
36             ct++;
37             p.push_back(i);
38         }
39     }
40     if(ct==0) cout<<-1<<endl;
41     else if(ct==1){
42         cout<<(n/p[0]+(n%p[0]!=0))<<endl;
43     }
44     else{
45         ans=(n/p[0]+(n%p[0]!=0));
46         for(int i=1;i<p.size();i++){
47             int a=n/p[i]+(n%p[i]!=0);
48             if(a!=ans){cout<<-1<<endl; return 0;}
49         }
50         cout<<ans<<endl;
51     }
52     return 0;
53 }
View Code

C. Did you mean...

题目意思:有一个字符串,如果有超过三个以上的辅音字母连续出现就需要添加一个空格,三个都是辅音字母都是一样的则不算,em…………直接模拟就好了,做的时候没有读懂题目的意思,简直GG

题目思路:每次发现累计三个辅音字母就判断一个三个是不是一样的,如果是就那么计数器减减,否则就在最后一个辅音字母输出的前面加一个空格,然后计数器清为1,如果碰到原因字母计数器清为0。

代码:

技术分享
 1 /* ***********************************************
 2 Author        :xiaowuga
 3 Created Time  :2017年10月02日 星期一 20时05分34秒
 4 File Name     :C.cpp
 5 ************************************************ */
 6 #include <bits/stdc++.h>
 7 #define mem(s,ch) memset(s,ch,sizeof(s))
 8 typedef long long LL; 
 9 #define inf 0x3f3f3f3f 
10 const long long N=1000000;
11 const long long mod=1e9+7;
12 using namespace std;
13 int check(char a){
14     if(a==a||a==e||a==i||a==o||a==u) return 1;
15     else return 0;
16 }
17 int main(){
18     ios::sync_with_stdio(false);cin.tie(0);
19     string q;
20     cin>>q;
21     int len=q.size();
22     int ct=0;
23     for(int i=0;i<len;i++){
24         if(!check(q[i])){
25             ct++;
26             if(ct>=3){
27                 if(q[i-1]==q[i]&&q[i]==q[i-2]) ct--;
28                 else {
29                     cout<< ;
30                     ct=1;
31                 }
32             }
33 
34         }    
35         else ct=0;
36         cout<<q[i];
37     }
38     cout<<endl;
39     return 0;
40 }
View Code

 

Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)

标签:mod   sync   using   cto   isp   define   type   http   splay   

原文地址:http://www.cnblogs.com/xiaowuga/p/7622935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!