Contest - 第10届“新秀杯”ACM程序设计大赛现场热身赛 赛后信息(题解)
| Problem Id | Title | |
| Problem A | A+B | |
| Problem B | 统计字数 | |
| Problem C | 生日计算 | |
| Problem D | 冬瓜的寒假之旅 |
Problem A(略)
Problem B
B题目就是一个统计字符的简单模拟,纵向记录横向输出就可。先for一圈遍历遍最大的个数可确定高度。
/****************************************/
/***** Desgard_Duan *****/
/****************************************/
//#pragma comment(linker, "/STACK:102400000,102400000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <functional>
#include <cmath>
#include <numeric> using namespace std; vector<string> ans;
int let[]; int main () {
string text = "", in;
for (int i = ; i < ; ++ i) {
getline(cin, in);
text += in;
}
//cout << text << endl;
memset (let, , sizeof (let));
int Max = ;
for (int i = ; i < text.size(); ++ i) {
if (isalpha(text[i])) {
let[text[i] - 'A'] ++;
Max = max (Max, let[text[i] - 'A']);
}
}
for (int i = ; i <= Max; ++ i) {
string text_line = "";
for (int j = ; j < ; ++ j) {
if (i > Max - let[j]) {
text_line += "*";
} else {
text_line += " ";
}
if (j != ) text_line += " ";
}
cout << text_line << endl;
}
puts("A B C D E F G H I J K L M N O P Q R S T U V W X Y Z");
return ;
}
Problem C
考虑闰年的2月29日生日就可,其他没有什么坑。
/****************************************/
/***** Desgard_Duan *****/
/****************************************/
//#pragma comment(linker, "/STACK:102400000,102400000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <functional>
#include <cmath>
#include <numeric> using namespace std; int judge( int x ) {
if( x % == || ( x % == && x % != ) )
return ;
return ;
}
int main() {
int y, m, d, t;
while(scanf( "%d", &t ) != EOF) {
while( t-- ) {
scanf( "%d-%d-%d", &y, &m, &d );
int sum = ;
if( judge( y ) && m == && d == && !judge( y + ) ) {
puts( "-1" );
continue;
}
for( int i = ; i <= ; ++i )
if(judge( y + i ))
sum ++;
if( judge( y + ) && m <= && d < )
--sum;
if( judge( y ) && m >= )
--sum;
printf( "%d\n", sum + * );
}
}
return ;
}
Problem D
主要考察枚举法。即全排列。在数据量不大的情况下,即可将TSP问题的所有情况全部列出,寻求最佳值。
另外可以学习一下next_permutation函数的用法,白书中也有介绍。
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue> using namespace std; int per[]; struct point {
double x, y;
} p[]; double dis(point a, point b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
} int main() {
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T, n, cas = ;
double ans;
bool f;
scanf("%d", &T);
while(T--) {
f = true;
scanf("%d", &n);
for(int i = ; i <= n; ++i) {
scanf("%lf%lf", &p[i].x, &p[i].y);
}
for(int i = ; i <= n; ++i) {
per[i - ] = i;
}
do {
point tmp;
tmp.x = ;
tmp.y = ;
double sum = dis(tmp, p[per[]]);
for(int i = ; i < n; ++i) {
sum += dis(p[per[i]], p[per[i - ]]);
}
sum += dis(tmp, p[per[n - ]]);
if(f) {
ans = sum;
f = false;
} else
ans = min(ans, sum);
} while(next_permutation(per, per + n));
printf("Case #%d: %.2lf\n", cas++, ans);
}
return ;
}

Contest - 第10届“新秀杯”ACM程序设计大赛现场热身赛 赛后信息(题解)的更多相关文章
- Contest - 第10届“新秀杯”ACM程序设计大赛网络预选赛 赛后信息(晋级名单)
经过比赛结果以及综合评定,以下42名同学暂定出现.下为出现名单(打*为 友情参赛 或为 有重大作弊嫌疑的选手). 在即日24时之前,若有异议,仍可申诉,申诉邮箱:desgard_duan@foxmai ...
- Contest - 第10届“新秀杯”ACM程序设计大赛网络资格赛 赛后信息(晋级名单·正式版)
2014_acm_fresh_0057 刘畅 20131620 2014_acm_fresh_0099 汪哲 20132185 2014_acm_fresh_0086 陈顺 2014111776 20 ...
- “玲珑杯”第七届郑州轻工业学院ACM程序设计大赛 ------- D:社交网络
题目链接: http://acm.zzuli.edu.cn/problem.php?cid=1099&pid=3 题目大意: 国语题目,题意显而易见, 解题思路: 只需要对每一个节点进行假设, ...
- 计算机学院2014年“新生杯”ACM程序设计大赛
1440: 棋盘摆车问题 对于输入n,k: 1.当n<k时,无满足的摆法 2.否则 第一个车可以排n*n个位置(即整个棋盘),第二个可排(n-1)*(n-1)个位置,…… 正如排列组合一样,车与 ...
- 第13届 广东工业大学ACM程序设计大赛 C题 平分游戏
第13届 广东工业大学ACM程序设计大赛 C题 平分游戏 题目描述 转眼间又过了一年,又有一届的师兄师姐要毕业了. 有些师兄师姐就去了景驰科技实习. 在景驰,员工是他们最宝贵的财富.只有把每一个人 ...
- 第十一届GPCT杯大学生程序设计大赛完美闭幕
刚刚过去的周六(6月7号)是今年高考的第一天,同一时候也是GPCT杯大学生程序设计大赛颁奖的日子,以下我们用图文再回想一下本次大赛颁奖的过程. 评审过程的一些花絮<感谢各位评审这些天的付出!&g ...
- 西南科技大学第十一届ACM程序设计大赛发言稿
西南科技大学第十一届ACM程序设计大赛发言稿 各位老师.志愿者及参赛选手: 大家好,我是来自计科学院卓软1301的哈特13,很荣幸今天能站在这里代表参赛选手发言. 回想起来,我参加ACM比赛已经快两年 ...
- nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)
题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...
- nyoj 1239 引水project (河南省第八届acm程序设计大赛)
题目1239 pid=1239" style="color:rgb(55,119,188)">题目信息 pid=1239" style="col ...
随机推荐
- javascript內容向上不間斷滾動
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 如何实现数字lcd显示效果(原创)
如题,我最先想到的是找一种字体,然后来显示lcd的效果,但是字体又无法满足有空位的时候那个暗灰色的文字的效果,如下所示 就是前三位那些灰色的888,因为你设置数值的时候只能是从0-9的数字,而这灰色的 ...
- NYOJ-569最大公约数之和
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=569 此题目可以用筛选法的思想来做,但是用到一个欧拉函数 gcd(1,12)=1,gcd( ...
- Vs2010发布Asp.Net网站及挂到IIS服务上
首先用vs2010打开一个Asp.Net项目, 也可以通过vs菜单->生成->发布网站 选择发布网站的路径 这样发布就OK了 下面就吧发 ...
- 关于禁止在 .NET Framework 中执行用户代码。启用 "clr enabled" 配置选项
这个问题是我新装好sql2008r2以后,我把服务器上的数据库还原到本地,取代码里跟踪测试的时候,出现的这个问题. 然后我在网上找了之后在sql里直接新建查询执行如下语句: exec sp_confi ...
- 关于HttpServlet和Servlet以及doPost和doGet关系
这两天在看Servlet和Jsp,spring太难了,还是先看看基础,只怪自己太弱了. Servlet是一个接口,本身定义的是一种网络服务,HttpServlet是已经实现了Servlet接口,也就是 ...
- 织梦DEDECMS {dede:field name='position'/}标签增加其它属性的
在默认情况下,织梦(DedeCms)系统当前位置的调用标签为: {dede:field name='position'/} 在这种默认的情况下,生成后的代码大致为如下格式: 主页 > 应用软件 ...
- linux的make install命令
tar zxvf redis-2.8.15.tar.gz cd redis-2.8.15/ make make test make install
- BestCoder Round 59 (HDOJ 5500) Reorder the Books
Problem Description dxy has a collection of a series of books called “The Stories of SDOI”,There are ...
- MySQL查询执行的基础
当希望MySQL能够以更高的性能运行查询时,最好的办法就是弄清楚MySQL是如何优化和执行查询的.一旦理解这一点,很多查询优化实际上就是遵循一些原则让优化器能够按照预想的合理的方式运行. 换句话说,是 ...