BestCoder Round #11 (Div. 2) 前三题题解
题目链接:
hdu5054 Alice and Bob
Alice and Bob
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 216 Accepted Submission(s): 166
corner of the Square, Alice in the upper right corner of the the Square. Bob regards the lower left corner as the origin of coordinates, rightward for positive direction of axis X, upward for positive direction of axis Y. Alice regards the upper right corner
as the origin of coordinates, leftward for positive direction of axis X, downward for positive direction of axis Y. Assuming that Square is a rectangular, length and width size is N * M. As shown in the figure:
Bob and Alice with their own definition of the coordinate system respectively, went to the coordinate point (x, y). Can they meet with each other ?
Note: Bob and Alice before reaching its destination, can not see each other because of some factors (such as buildings, time poor).
10 10 5 5
10 10 6 6
YES
NO
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#define eps 1e-9
#define ll long long
#define INF 0x3f3f3f3f
using namespace std; int main()
{
int x,y,n,m;
while(scanf("%d%d%d%d",&n,&m,&x,&y)!=EOF)
{
if(2*x==n&&2*y==m)
printf("YES\n");
else
printf("NO\n");
}
}
hdu 5055 Bob and math problem
Bob and math problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 643 Accepted Submission(s): 245
There are N Digits, each digit is between 0 and 9. You need to use this N Digits to constitute an Integer.
This Integer needs to satisfy the following conditions:
- 1. must be an odd Integer.
- 2. there is no leading zero.
- 3. find the biggest one which is satisfied 1, 2.
Example:
There are three Digits: 0, 1, 3. It can constitute six number of Integers. Only "301", "103" is legal, while "130", "310", "013", "031" is illegal. The biggest one of odd Integer is "301".
Each case starts with a line containing an integer N ( 1 <= N <= 100 ).
The second line contains N Digits _1, a_2, a_3, \cdots, a_n. ( 0 \leqwhich indicate the digit $a a_i \leq 9)$.
3
0 1 3
3
5 4 2
3
2 4 6
301
425
-1
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#define eps 1e-9
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=100+10;
int a[maxn],odd[maxn];
char str[maxn];
int n; int main()
{
int ans,pd;
while(scanf("%d",&n)!=EOF)
{
memset(str,0,sizeof(str));
int cnt=0,first=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]%2)
odd[++cnt]=a[i];
}
sort(odd+1,odd+1+cnt);
sort(a+1,a+1+n);
int ly=n-1;
if(cnt==0)
puts("-1");
else
{
str[ly]=odd[1]+'0';
ly--;
for(int i=1;i<=n;i++)
{
if(a[i]==odd[1]&&!first)
{
first=1;
continue;
}
else
{
str[ly]=a[i]+'0';
ly--;
}
}
if(str[0]=='0')
puts("-1");
else
{
for(int i=0;i<=n-1;i++)
printf("%c",str[i]);
printf("\n");
}
}
}
return 0;
}
Boring count
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 451 Accepted Submission(s): 169
For each case, the first line contains a string which only consist of lowercase letters. The second line contains an integer K.
[Technical Specification]
1<=T<= 100
1 <= the length of S <= 100000
1 <= K <= 100000
3
abc
1
abcabc
1
abcabc
2
6
15
21
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#define eps 1e-9
#define ll long long
#define INF 0x3f3f3f3f
using namespace std; const int maxn=100000+10;
char str[maxn];
int cnt[28]; int main()
{
ll ans;
int t,st,k,ly;
scanf("%d",&t);
while(t--)
{
memset(cnt,0,sizeof(cnt));
st=ans=0;
scanf("%s%d",str,&k);
for(int i=0;str[i]!='\0';i++)
{
ly=str[i]-'a';
cnt[ly]++;
if(cnt[ly]>k)
{
while(str[st]!=str[i])
{
cnt[str[st]-'a']--;
st++;
}
cnt[ly]--;
st++;
}
ans+=i-st+1;
}
printf("%I64d\n",ans);
}
return 0;
}
BestCoder Round #11 (Div. 2) 前三题题解的更多相关文章
- Lyft Level 5 Challenge 2018 - Final Round (Open Div. 2) (前三题题解)
这场比赛好毒瘤哇,看第四题好像是中国人出的,怕不是dllxl出的. 第四道什么鬼,互动题不说,花了四十五分钟看懂题目,都想砸电脑了.然后发现不会,互动题从来没做过. 不过这次新号上蓝名了(我才不告诉你 ...
- Codeforces Round #609 (Div. 2)前五题题解
Codeforces Round #609 (Div. 2)前五题题解 补题补题…… C题写挂了好几个次,最后一题看了好久题解才懂……我太迟钝了…… 然后因为longlong调了半个小时…… A.Eq ...
- Codeforces Round #460 (Div. 2) 前三题
Problem A:题目传送门 题目大意:给你N家店,每家店有不同的价格卖苹果,ai元bi斤,那么这家的苹果就是ai/bi元一斤,你要买M斤,问最少花多少元. 题解:贪心,找最小的ai/bi. #in ...
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
- BestCoder Round #11 (Div. 2) 题解
HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- bestcoder Round #7 前三题题解
BestCoder Round #7 Start Time : 2014-08-31 19:00:00 End Time : 2014-08-31 21:00:00Contest Type : ...
- BestCoder Round #85 前三题题解
sum Accepts: 822 Submissions: 1744 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/13107 ...
- Codeforces Round #530 (Div. 2) (前三题题解)
总评 今天是个上分的好日子,可惜12:30修仙场并没有打... A. Snowball(小模拟) 我上来还以为直接能O(1)算出来没想到还能小于等于0的时候变成0,那么只能小模拟了.从最高的地方进行高 ...
- BestCoder Round #11 (Div. 2)
太菜,仅仅能去Div2.(都做不完 ORZ... 各自是 HDU: 5054pid=5054"> Alice and Bob 5055Bob and math problem 5056 ...
随机推荐
- 怎么成为合格的WEB前端开发工程师
web前端开发工程师目前来讲是一个热门职位,但是要成为一个合格的web前端开发工程师,需要掌握的知识可不少,零度就简单的为大家讲讲. 大致的来讲,web前端开发工程师需要掌握的知识有:HTML.CSS ...
- C#开发 —— 泛型,文件
泛型的目标是采用广泛适用和可交互性的形式来表示算法和数据结构 —— 参数化 泛型能子啊编译时提供强大的类型检查,减少数据类型之间的显式转换,装箱操作和运行时的类型检查 泛型的类型参数T可以被看作是一个 ...
- docker部署mysql 实现远程连接
1. docker search mysql # 查看mysql版本 2. docker pull mysql:5.7 # 拉取mysql 5.7 3. docker images # 查 ...
- 【Hello 2018 A】 Modular Exponentiation
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 当a<b的时候 a%b==a 显然2^n增长很快的. 当2^n>=1e8的时候,直接输出m就可以了 [代码] #incl ...
- 【hdu 6038】Function
[Link]:http://codeforces.com/contest/834/problem/C [Description] 给你两个排列a和b; a排列的长度为n,b排列的长度为m; a∈[0. ...
- FZU 1608 Huge Mission
Huge Mission Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original I ...
- src/MD2.c:31:20: 错误:Python.h:没有那个文件或目录
一.前言 在CentOS 上安装fabric时出现问题,首先已安装pip, 用pip执行以下命令pip install 出现以下问题 [niy@niy-computer /]$ sudo pip in ...
- [ReasonML] Workshops code
/* list of strings */ let _ = ["example-1", "example-2", "example-3"]; ...
- 01-Jvm 内存区域复习笔记
Java内存区域 1.程序计数器(Program Counter Register) 在虚拟机中一块较小的内存空间.它的作用能够看做是当前线程所运行的字节码的行号指示 ...
- widget-移除底部小部件内容
今天有一个要求,就是在调出手机窗口小部件的时候,让其中的某些小部件不显示.折腾了好久,虽然不知道原理,最终还是实现了屏蔽其中个别小部件的方法.记录下来 要想屏蔽底部小部件的显示,只需要把相关的类跟广播 ...