Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)
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
代码:
/* ***********************************************
Author :xiaowuga
Created Time :2017年10月02日 星期一 18时00分24秒
File Name :A.cpp
************************************************ */
#include <bits/stdc++.h>
#define mem(s,ch) memset(s,ch,sizeof(s))
typedef long long LL;
#define inf 0x3f3f3f3f
const long long N=;
const long long mod=1e9+;
using namespace std;
int main(){
ios::sync_with_stdio(false);cin.tie();
LL n,k;
cin>>n>>k;
LL c1=,c2=;
LL t=n;
while(t%==){
c1++;
t/=;
}
while(t%==){
c2++;
t/=;
}
while(c1<k) c1++;
while(c2<k) c2++;
for(int i=;i<c1;i++){
t*=;
}
for(int i=;i<c2;i++){
t*=;
}
cout<<t<<endl;
return ;
}
B. Which floor?
题目意思:小明住在一个每层楼都有相同数量房间的大楼里面,但是他忘记每层楼有多少个房间了。现在他只记得某些房间在几楼,现在让你根据小明的记忆,判断编号为n的房间在哪一楼是否可以确定。(房间的编号从1-n)从底层到高层;
题目思路:我们发现数据范围很小,这意味这我们可以暴力枚举每层有多少间房间,然后和小明的记忆进行比对,然后把符合小明记忆的数量存起来,然后最后判断他们指出编号为n的房间的楼层是否相同,如果不同就输出-1.
题目链接:http://codeforces.com/contest/861/problem/B
代码:
/* ***********************************************
Author :xiaowuga
Created Time :2017年10月02日 星期一 18时48分45秒
File Name :B.cpp
************************************************ */
#include <bits/stdc++.h>
#define mem(s,ch) memset(s,ch,sizeof(s))
typedef long long LL;
#define inf 0x3f3f3f3f
const long long N=;
const long long mod=1e9+;
using namespace std;
vector<pair<int,int> >q;
vector<int>p;
int main(){
ios::sync_with_stdio(false);cin.tie();
int n,k;
cin>>n>>k;
q.resize(k+);
for(int i=;i<k;i++) {
cin>>q[i].first>>q[i].second;
}
int ct=;
int ans=;
for(int i=;i<=;i++){
int cnt=;
for(int j=;j<k;j++){
int x=q[j].first,y=q[j].second;
int l;
if(x%i==) l=;else l=;
int z=x/i+l;
if(z==y) cnt++;
else break;
}
if(cnt==k){
ct++;
p.push_back(i);
}
}
if(ct==) cout<<-<<endl;
else if(ct==){
cout<<(n/p[]+(n%p[]!=))<<endl;
}
else{
ans=(n/p[]+(n%p[]!=));
for(int i=;i<p.size();i++){
int a=n/p[i]+(n%p[i]!=);
if(a!=ans){cout<<-<<endl; return ;}
}
cout<<ans<<endl;
}
return ;
}
C. Did you mean...
题目意思:有一个字符串,如果有超过三个以上的辅音字母连续出现就需要添加一个空格,三个都是辅音字母都是一样的则不算,em…………直接模拟就好了,做的时候没有读懂题目的意思,简直GG
题目思路:每次发现累计三个辅音字母就判断一个三个是不是一样的,如果是就那么计数器减减,否则就在最后一个辅音字母输出的前面加一个空格,然后计数器清为1,如果碰到原因字母计数器清为0。
代码:
/* ***********************************************
Author :xiaowuga
Created Time :2017年10月02日 星期一 20时05分34秒
File Name :C.cpp
************************************************ */
#include <bits/stdc++.h>
#define mem(s,ch) memset(s,ch,sizeof(s))
typedef long long LL;
#define inf 0x3f3f3f3f
const long long N=;
const long long mod=1e9+;
using namespace std;
int check(char a){
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u') return ;
else return ;
}
int main(){
ios::sync_with_stdio(false);cin.tie();
string q;
cin>>q;
int len=q.size();
int ct=;
for(int i=;i<len;i++){
if(!check(q[i])){
ct++;
if(ct>=){
if(q[i-]==q[i]&&q[i]==q[i-]) ct--;
else {
cout<<' ';
ct=;
}
} }
else ct=;
cout<<q[i];
}
cout<<endl;
return ;
}
Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)的更多相关文章
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861C Did you mean...【字符串枚举,暴力】
C. Did you mean... time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861B Which floor?【枚举,暴力】
B. Which floor? time limit per test:1 second memory limit per test:256 megabytes input:standard inpu ...
- Codeforces Round #434 (Div. 2, based on Technocup 2018 Elimination Round 1)&&Codeforces 861A k-rounding【暴力】
A. k-rounding time limit per test:1 second memory limit per test:256 megabytes input:standard input ...
- 【模拟】 Codeforces Round #434 (Div. 1, based on Technocup 2018 Elimination Round 1) C. Tests Renumeration
题意:有一堆数据,某些是样例数据(假设X个),某些是大数据(假设Y个),但这些数据文件的命名非常混乱.要你给它们一个一个地重命名,保证任意时刻没有重名文件的前提之下,使得样例数据命名为1~X,大数据命 ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
A. Search for Pretty Integers 题目链接:http://codeforces.com/contest/872/problem/A 题目意思:题目很简单,找到一个数,组成这个 ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) D. Something with XOR Queries
地址:http://codeforces.com/contest/872/problem/D 题目: D. Something with XOR Queries time limit per test ...
- Codeforces Round #440 (Div. 1, based on Technocup 2018 Elimination Round 2) C - Points, Lines and Ready-made Titles
C - Points, Lines and Ready-made Titles 把行列看成是图上的点, 一个点(x, y)就相当于x行 向 y列建立一条边, 我们能得出如果一个联通块是一棵树方案数是2 ...
- Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2) C. Maximum splitting
地址: 题目: C. Maximum splitting time limit per test 2 seconds memory limit per test 256 megabytes input ...
- ACM-ICPC (10/15) Codeforces Round #440 (Div. 2, based on Technocup 2018 Elimination Round 2)
A. Search for Pretty Integers You are given two lists of non-zero digits. Let's call an integer pret ...
随机推荐
- perl 函数的参数列表
在perl中,定义一个函数的时候,不需要在圆括号内指定具体的参数,所有的参数都从@_ 这个列表中得到 代码示例: sub test { my ($a, $b) = @_; print qq{$a\t$ ...
- CentOS系统中的passwd命令实用技巧小结
这篇文章主要介绍了Linux系统中的passwd命令实用技巧小结,是Linux入门学习中的基础知识,需要的朋友可以参考下 先来回顾一下passwd命令的基本用法: Linux passwd命令用来 ...
- 最短路径问题-Dijkstra
概述 与前面说的Floyd算法相比,Dijkstra算法只能求得图中特定顶点到其余所有顶点的最短路径长度,即单源最短路径问题. 算法思路 1.初始化,集合K中加入顶点v,顶点v到其自身的最短距离为0, ...
- centos7 systemctl
下机为systemctl指令systemctl enable *.service #开机运行服务systemctl disable *.service #取消开机运行systemctl start * ...
- System.Func<>与System.Action<>
使用并行编程可以同时操作多个委托,在介绍并行编程前先简单介绍一下两个泛型委托System.Func<>与System.Action<>. Func<>是一个能接受多 ...
- 5、Cocos2dx 3.0游戏开发找小三之測试例子简单介绍及小结
重开发人员的劳动成果.转载的时候请务必注明出处:http://blog.csdn.net/haomengzhu/article/details/27186557 測试例子简单介绍 Cocos2d-x ...
- SQLServer------插入数据时出现IDENTITY_INSERT错误
详细错误信息: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'Student' 中的标识列插入显式值. 原因: 表中存在某个字段是自动增长的标识符 解决方法: set IDENT ...
- JBPM4.4_jBPM4.4的流程定义语言(设计流程)
1. jBPM4.4的流程定义语言(设计流程) 1.1. process(流程) 是.jpdl.xml的根元素,可以指定的属性有: 属性名 作用说明 name 流程定义的名称,用于显示. key 流程 ...
- 【RF库Collections测试】Get Dictionary Keys
Name:Get Dictionary KeysSource:Collections <test library>Arguments:[ dictionary ]Returns `keys ...
- Linux mysqladmin 命令
mysqladmin命令可以用来设置或修改 MySQL 密码,常见用法如下: [root@localhost ~]$ mysqladmin -uroot password 'newPass' # 在无 ...