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( ...
随机推荐
- CSS中的“>”是什么意思
#quickSummary p{color:red;} #quickSummary >p+p{color:red;} #quickSummary>p+p+p{color:inherit;} ...
- hdu 1556 Color the ball(区间更新,单点求值)
Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- 2012-2013 Northwestern European Regional Contest (NWERC 2012)
B - Beer Pressure \(dp(t, p_1, p_2, p_3, p_4)\)表示总人数为\(t\),\(p_i\)对应酒吧投票人数的概率. 使用滚动数组优化掉一维空间. 总的时间复杂 ...
- 浅谈LOG日志的写法
文章来源于公司的大牛 1 Log的用途 不管是使用何种编程语言,日志输出几乎无处不再.总结起来,日志大致有以下几种用途: l 问题追踪:通过日志不仅仅包括我们程序的一些bug,也可以在安装配置时,通 ...
- H3C 递归查询
- H3C 端口隔离配置举例
- H3C配置BPDU的生成和传递
- 移动端android上line-height不居中的问题的解决
废话不多话,直接上代码,如下: .btn { width: 1.5rem; max-width: 100px; text-align: center; height: .56rem; font-wei ...
- 洛谷——P1160 队列安排(链表的基础操作)
#include<bits/stdc++.h> using namespace std; ]; list<int> stus; list<];//用来存放每一项的迭代器 ...
- 由“Sysnative”引发的思考
在64位的Windows系统中,有个非常神秘的文件夹“Sysnative”,你无法通过Explorer去访问它,甚至你都无法找到它,但它却扮演了一个非常重要的角色.下面我们就来聊聊它. 32位和64位 ...