2016女生专场 ABCDEF题解 其他待补...
GHIJ待补...
A.HUD5702:Solving Order
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3550 Accepted Submission(s): 2149

As a pretty special competition, many volunteers are preparing for it with high enthusiasm.
One thing they need to do is blowing the balloons.
Before sitting down and starting the competition, you have just passed by the room where the boys are blowing the balloons. And you have found that the number of balloons of different colors are strictly different.
After thinking about the volunteer boys' sincere facial expressions, you noticed that, the problem with more balloon numbers are sure to be easier to solve.
Now, you have recalled how many balloons are there of each color.
Please output the solving order you need to choose in order to finish the problems from easy to hard.
You should print the colors to represent the problems.
And as for each case, the first line is an integer n, which is the number of problems.
Then there are n lines followed, with a string and an integer in each line, in the i-th line, the string means the color of ballon for the i-th problem, and the integer means the ballon numbers.
It is guaranteed that:
T is about 100.
1≤n≤10.
1≤ string length ≤10.
1≤ bolloon numbers ≤83.(there are 83 teams :p)
For any two problems, their corresponding colors are different.
For any two kinds of balloons, their numbers are different.
There should be n strings in the line representing the solving order you choose.
Please make sure that there is only a blank between every two strings, and there is no extra blank.
题意:
将气球按数量排序从大到小输出
题解:
排序输出
#include <stdio.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
const int N = +;
const int INF = 0x3f3f3f3f;
struct node{
string s;
int num;
}a[N];
bool cmp(node x,node y){
return x.num>y.num;
}
int main(){
int T,n;
for (scanf("%d",&T);T;T--){
scanf("%d",&n);
for(int i=;i<n;i++){
cin>>a[i].s>>a[i].num;
}
sort(a,a+n,cmp);
for (int i=;i<n;i++) {
cout<<a[i].s<< ((i==n-)?"\n":" ");
}
}
return ;
}
B.HUD5703:Desert
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2586 Accepted Submission(s): 1660
Write a program to calculate how many different ways the tourist can drink up the water.
Next T lines contain the number n(1≤n≤1000000) for each test case.
Each line contains the binary number which represents number of different ways to finish up the water specified in the test case.
3 liters of water can be comsumed in four different ways show in the following.
If we write 4 in binary, it's 100.
题意:
一共有n升水,每天必须喝正整数升,问有几种不同的方法。
既,用正整数组成n有多少种组成方法。
用二进制方式输出。
题解:
这题是打表找的规律,列出前几项之后发现f(n)=2n-1。
#include <stdio.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
int main(){
int T,n;
for (scanf("%d",&T);T;T--){
scanf("%d",&n);
printf("");
for (int i=;i<n;i++){
printf("");
}
printf("\n");
}
return ;
}
C.HDU5704:Luck Competition
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1775 Accepted Submission(s): 1087
If you are given a chance to know how many people are participating the competition and what their numbers are, calculate the highest number with the highest probability to win assuming that you're joining the competition.
Each test case begins with an integer N(1<N≤100), denoting the number of participants. And next line contains N−1 numbers representing the numbers chosen by other participants.
题意:
n个人参加比赛,每个人选择一个非负整数,谁选的数小于且最接近 这些数的平均数的2/3 ,谁就可能成为幸运者,现在已知有n个人,给出n-1个人选的数,第n个人是你,你要成为幸运者应该选择哪个数,以及你选择了这个数之后能成为幸运者的概率是多少。
题解:
根据题目我们可以推出幸运数x满足:
x≤ (x+sum)/n * 2/3 => x≤ (2*sum)/(3*n-2) 其中sum为n-1个数的和,n为n个人。
#include <stdio.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
int main(){
int T,n,x;
for (scanf("%d",&T);T;T--){
scanf("%d",&n);
int sum = ,a[]={};
for (int i=;i<n;i++){
scanf("%d",&x);
a[x]++;
sum+=x;
}
int ans = (int)(2.0*sum/(3.0*n-));
a[ans]++;
printf("%d %.2f\n", ans,1.0/a[ans]);
}
return ;
}
D.HDU5705:Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 1707 Accepted Submission(s): 625
1. The angle formed by the hour hand and the minute hand is a.
2. The time may not be a integer(e.g. 12:34:56.78), rounded down(the previous example 12:34:56).
Each test case contains two lines.
The first line is the time HH:MM:SS(0≤HH<12,0≤MM<60,0≤SS<60).
The second line contains one integer a(0≤a≤180).
题意:
给出时间t和角度a,求时间t之后 时针和分针呈a°角的时刻。如果不是整数则向下取整。
题解:
我们知道时针每120秒走1°,分针每10秒走1°,既每隔120秒时针分针差11°,我们可以把a扩大11倍 a*=11。
所以我们可以从120秒开始枚举。当枚举的时间恰好时针分针差a°且大于时间t的时候得到结果,因为之前乘了11所以结果要除以11。
这里我们要注意0≤a≤180,所以当我们算的过程中的度数 b 大于180×11 时,时针和分针的实际度数为360*11-b。
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
const int N = +;
const int INF = 2e9+;
int dp[N][N]={,};
char a[N],b[N],c[N];
int main() {
int h,m,s,a,cnt=;
while (~scanf("%d:%d:%d %d",&h,&m,&s,&a)){
int t = (h*+m*+s)*;
a*=;
int b = ,b1,tt;
for (tt=;;tt+=){
b+=;
b1=b%(*);
if (b1>*) {
b1 = (*)-b1;
}
if(b1 == a&&tt>t){
break;
}
}
tt = tt%(**); // 避免时间大于12小时
h = tt / (*);
m = (tt - h * *) / (*);
s = (tt - h * * - m * *) / ;
printf("Case #%d: %02d:%02d:%02d\n",cnt++,h,m,s);
}
return ;
}
E.HDU5706:GirlCat
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1955 Accepted Submission(s): 1155
Under the influence of Kotori, many girls and cats are playing ``Hide and Seek'' together.
Koroti shots a photo. The size of this photo is n×m, each pixel of the photo is a character of the lowercase(from `a' to `z').
Kotori wants to know how many girls and how many cats are there in the photo.
We define a girl as -- we choose a point as the start, passing by 4 different connected points continuously, and the four characters are exactly ``girl'' in the order.
We define two girls are different if there is at least a point of the two girls are different.
We define a cat as -- we choose a point as the start, passing by 3 different connected points continuously, and the three characters are exactly ``cat'' in the order.
We define two cats are different if there is at least a point of the two cats are different.
Two points are regarded to be connected if and only if they share a common edge.
As for each case, the first line are two integers n and m, which are the height and the width of the photo.
Then there are n lines followed, and there are m characters of each line, which are the the details of the photo.
It is guaranteed that:
T is about 50.
1≤n≤1000.
1≤m≤1000.
∑(n×m)≤2×106.
There should be 2 integers in the line with a blank between them representing the number of girls and cats respectively.
Please make sure that there is no extra blank.
0 2
4 1
题意:
找图中有多少个girl和cat。如果连着走4步,是"girl"就是一个girl;如果连着走3步,是"cat"就是一只cat。字符可重复使用,只要有一个字符位置不同就是不同的。
题解:
可以用搜索来写,遇到g或c就搜它和它周围的字符能否组成girl或cat。
#include <stdio.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
const int N = +;
const int INF = 0x3f3f3f3f;
int n,m,ans1,ans2;
char s[N][N];
int d[][]={,,,,,-,-,};
char s1[][]={"girl","cat"};
bool in(int x,int y){
return x<n&&x>=&&y<m&&y>=;
}
void dfs(int x,int y,int type,int k){
if (type== && k==){
ans1++;
return;
}else if (type== && k==){
ans2++;
return;
}
for (int i=;i<;i++){
int xx = x+d[i][];
int yy = y+d[i][];
if (in(xx,yy)&&s[xx][yy]==s1[type][k]){
dfs(xx,yy,type,k+);
}
}
}
int main(){
int T;
for (scanf("%d",&T);T;T--){
ans1=ans2=;
scanf("%d%d",&n,&m);
for (int i=;i<n;i++)
scanf("%s",s[i]);
for (int i=;i<n;i++){
for (int j = ;j<m;j++){
if (s[i][j] == 'g'){
dfs(i,j,,);
}else if (s[i][j] == 'c'){
dfs(i,j,,);
}
}
}
printf("%d %d\n", ans1,ans2);
}
return ;
}
F.HDU5707:Combine String
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 3853 Accepted Submission(s): 1048
A string c is said to be the combine string of a and b if and only if c can be broken into two subsequences, when you read them as a string, one equals to a, and the other equals to b.
For example, ``adebcf'' is a combine string of ``abc'' and ``def''.
Each test case contains three strings a, b and c (the length of each string is between 1 and 2000).
题意:
给你三个串a,b,c。将c拆成两个子序列,问能否正好拆成a,b。
题解:
这题贪心显然是不行的。我们可以用DP来写:
dp[i][j] 表示 c串前i+j个字符是否和a串的前i项以及b串的前j项匹配。
状态转移方程为:
if (i>0) {
dp[i][j] |= dp[i-1][j]&(a[i-1]==c[i+j-1]);
}
if (j>0) {
dp[i][j] |= dp[i][j-1]&(b[j-1]==c[i+j-1]);
}
#include <stdio.h>
#include <string.h>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define exp 1e-8
using namespace std;
const int N = +;
const int INF = 2e9+;
int dp[N][N]={,};
char a[N],b[N],c[N];
int main() {
while (~scanf("%s%s%s",a,b,c)){
int la=strlen(a),lb=strlen(b),lc=strlen(c);
if (la + lb != lc) {
printf("No\n");
continue;
}
memset(dp,,sizeof(dp));
dp[][] = ;
for (int i = ; i <= la; i++) {
for (int j = ;j <= lb; j++) {
if (i) {
dp[i][j] |= dp[i-][j]&(a[i-]==c[i+j-]);
}
if (j) {
dp[i][j] |= dp[i][j-]&(b[j-]==c[i+j-]);
}
}
}
printf("%s\n",dp[la][lb]?"Yes":"No");
}
return ;
}
其他待补...
2016女生专场 ABCDEF题解 其他待补...的更多相关文章
- HDU 6024(中国大学生程序设计竞赛女生专场1002)
这是CCPC女生专场的一道dp题.大佬们都说它简单,我并没有感到它有多简单. 先说一下题意:在一条直线上,有n个教室,现在我要在这些教室里从左到右地建设一些作为糖果屋,每个教室都有自己的坐标xi 和建 ...
- 2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)
Deleting Edges Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017中国大学生程序设计竞赛 - 女生专场 Happy Necklace(递推+矩阵快速幂)
Happy Necklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 2017中国大学生程序设计竞赛 - 女生专场(Graph Theory)
Graph Theory Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)To ...
- 2017中国大学生程序设计竞赛 - 女生专场(dp)
Building Shops Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...
- 2016女生赛 HDU 5710 Digit-Sum(数学,思维题)
Digit-Sum Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total S ...
- HDU 5705 Clock(2016杭电女生专场1004)——角度追及问题
题意是给出一个当前的时间和角度a,问从现在开始的下一个时针和分针形成角度a的时间是多少,时间向下取整. 分析:时针3600s走30°,故120s走1°,分针3600s走360°,故10s走1°,那么每 ...
- 2019中国大学生程序设计竞赛-女生专场(重现赛)部分题解C-Function(贪心+优先队列) H-clock(模拟)
Function 题目链接 Problem Description wls 有 n 个二次函数 Fi(x) = aix2 + bix + ci (1 ≤ i ≤ n). 现在他想在∑ni=1xi = ...
- COGS 2416.[HZOI 2016]公路修建 & COGS 2419.[HZOI 2016]公路修建2 题解
大意: [HZOI 2016]公路修建 给定一个有n个点和m-1组边的无向连通图,其中每组边都包含一条一级边和一条二级边(连接的顶点相同),同一组边中的一级边权值一定大于等于二级边,另外给出一个数k( ...
随机推荐
- oralce 分离表和索引
总是将你的表和索引建立在不同的表空间内(TABLESPACES). 决不要将不属于ORACLE内部系统的对象存放到SYSTEM表空间里. 同时,确保数据表空间和索引表空间置于不同的硬盘上. “同时 ...
- 洛谷P2146 [NOI2015]软件包管理器 题解 树链剖分+线段树
题目链接:https://www.luogu.org/problem/P2146 本题涉及算法: 树链剖分: 线段树(区间更新及求和,涉及懒惰标记) 然后对于每次 install x ,需要将 x 到 ...
- 利用谓词实现List<>的Find等高级操作
public class Person { public int Id { get; set; } public string Name { ...
- pycharm下的多个python版本共存(二)
上一篇博文介绍了在windows下同时安装python2和python3.而在工作的过程中,我习惯于用pycharm作为IDE.本文将记录如何在pycharm中选择python版本,并给相应的版本安装 ...
- js基础——正则表达式
1.创建方式: var box = new RegExp('box');//第一个参数字符串 var box = new RegExp('box','ig');//第二个参数可选模式修饰符 等同于 v ...
- P1093 铺地毯
题目描述 为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯.一共有 \(n\) 张地毯,编号从 \(1\) 到 \(n\) .现在将这些地毯按 ...
- SpringMVC 非注解配置
web.xml配置: <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>o ...
- Echarts构建图表
Echarts学习-构建图表 相信有很多的前端开发人员在开发Echarts图表的过程中都遇到对图表结构过无从下手,面对一大堆的专业词汇一脸懵逼的样子,在经过了一段时间的踩坑后,终于摸索出了一套完善的学 ...
- 51nod 1282 时钟
1282 时钟 题目来源: Codility 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有N个时钟,每个时钟有M个指针,P个刻度.时钟是圆形的,P个刻度均分 ...
- The Preliminary Contest for ICPC Asia Nanjing 2019ICPC南京网络赛
B.super_log (欧拉降幂) •题意 定一个一个运算log*,迭代表达式为 给定一个a,b计算直到迭代结果>=b时,最小的x,输出对m取余后的值 •思路 $log*_{a}(1)=1+l ...