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 ...
随机推荐
- gzip优化网络传输量提高传输效率[转]
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;us ...
- TN2151:崩溃报告
understanding and analyzing ios application crashreports 这个TN涉及了与崩溃相关的 内存耗尽信息,堆栈信息 以及 异常编号 等信息 内存耗尽 ...
- 将Apache添加为Linux的服务 实现自启动(转)
在Linux下用源代码方式编译安装完Apache后,启动关闭Apache可以通过如下命令实现: /app/apache2.2.14/bin/apachectl start | stop | resta ...
- ViewPage 大圣归来 原生示例
VP简介 android-support-v4.jar 是谷歌官方给我们提供的一个兼容低版本安卓设备的软件包,里面包囊了只有在安卓3.0以上可以使用的api.而ViewPage就是其中之一,利用它,我 ...
- WCF 接收我服务的 HTTP 响应时发生错误
错误内容: System.ServiceModel.CommunicationException: 接收对 https://xx.com/xx.svc的 HTTP 响应时发生错误.这可能是由于服务终结 ...
- W3C小组宣布:HTML5标准制定完成
近日,W3C小组宣布已经完成对HTML5标准以及Canvas 2D性能草案的制定,这就意味着开发人员将会有一个稳定的“计划和实施”目标. Web性能工作组已经推出W3C的两个版本建议草案. Navig ...
- java静态代码块 类加载顺序问题。
class B extends Object { static {System.out.println("Load B");} public B(){System.out.prin ...
- 安全管理:IE6安全隐患重重 为何不离不弃
安全服务商Zscaler的报告称,尽管微软IE6曾遭受一系列强势攻击并且新出的IE版本有更强的安全性能,但IE6依然受到各企业的热捧. 尽管微软一直敦促用户部署浏览器更新(截止2010年八月就将满九年 ...
- InstallShield 覆盖安装
“吾乐吧软件站”提供了很全面详细的InstallShield制作安装包教程(http://www.wuleba.com/23892.html),但是按上面的方法再次制作的升级安装包,安装后会在系统中同 ...
- [转载] 关于“淘宝应对"双11"的技术架构分析”
微博上一篇最新的关于“淘宝应对"双11"的技术架构分析”.数据产品的一个最大特点是数据的非实时写入.