A、Ace of Aces(ZOJ 3869)
有n个人投票,求出来票数最多的那个人的id。如果多个人票数一样,输出“Nobody”。

#include <stdio.h>
#include <string.h>#define N 1010int num[N];int main(void)
{int t;scanf("%d", &t);while (t--) {int n;scanf("%d", &n);memset(num, 0, sizeof(num));for (int i = 0; i <n ;++i) {int x;scanf("%d", &x);num[x]++;}int pos = 1;int flag = 0;for (int i = 1; i <=1000; ++i) {if (num[pos] < num[i]) {pos = i; }    }int m = 0;for (int i = 1; i <= 1000; ++i) {if (num[i] == num[pos]) {++m;}}if (m ==  1) {printf("%d\n", pos);} else {printf("Nobody\n");}}return 0;
}

B、Team Formation(ZOJ 3870)
有n个数,从这n个数中任选两个数a,b,问有多少组数满足a^b > max(a, b)。
我们假定有两个数x,y。其中1

#include <cstdio>
#include <cstring>
#include <cstdlib>#include <iostream>
#include <algorithm>using namespace std;#define N 100010typedef long long ll;// mp[i], number >= 2^i && < 2^(i+1)
ll num[N], mp[40];ll get2(ll n)
{int res = 0;while (n) {n >>= 1;++res;}return res - 1;
}int main(void)
{int t;scanf("%d", &t);while (t--) {int n;scanf("%d", &n);for (int i = 0; i < n; ++i) {scanf("%d", &num[i]);}sort(num, num + n);memset(mp, 0, sizeof(mp));for (int i = 0; i < n; ++i) {int idx = get2(num[i]);mp[idx]++;}ll ans = 0;for (int i = 0; i < n; ++i) {int a = num[i];int m = 0;while (a) {if ((a & 1) == 0) {ans += mp[m];//printf("%d...\n", mp[m]);}a >>= 1;++m;}}printf("%d\n", ans);}return 0;
}

D、Beauty of Array(ZOJ 3872)
定义了一个数组的美丽值,就是数组中不同数值加起来的和。让求的是给定一个数组中所有连续的子数组的美丽值的和。我们用dp[i]表示前i个数连续字数组的美丽值的和。
每加进来一个数,dp[i+1]要在加上dp[i]的基础上额外加上某些num[i + 1],这取决于之前最后一次出现num[i + 1]的位置,用另外一个组数记录这个位置就行了。

#include <cstdio>
#include <cstring>
#include <cstdlib>#include <iostream>
#include <algorithm>using namespace std;typedef long long ll;#define N 100010ll num[N], dp[N];
int vis[1000010];int main(void)
{int t;scanf("%d", &t);while (t--) {int n;scanf("%d", &n);for (int i = 1; i <= n; ++i) {scanf("%lld", &num[i]);}memset(vis, 0, sizeof(vis));memset(dp, 0, sizeof(dp));dp[1] = num[1];ll sum = num[1];vis[num[1]] = 1;for (int i = 2; i <= n; ++i) {dp[i] = dp[i - 1];// 两种情况可以合成一种 //if (!vis[num[i]]) {//  vis[num[i]] = i;//  dp[i] += i * num[i];//} else {dp[i] += (i - vis[num[i]]) * num[i];vis[num[i]] = i;//}sum += dp[i];}printf("%lld\n", sum);}return 0;
}

G、Lunch Time(ZOJ 3875)
简单的求中位数的,不过偶数的情况是取贵的那一个菜。因为有三种菜,计算三次就行了。

#include <cstdio>
#include <cstring>
#include <cstdlib>#include <iostream>
#include <algorithm>using namespace std;#define N 110struct Node {char name[N];int val;void input(void){scanf("%s%d", name, &val);}
}x[N], y[N], z[N];char ans[N * 2];
int cnt;bool cmp(Node u, Node v)
{return u.val < v.val;
}int f(Node node[], int n)
{//printf("%d %d %s...\n", n / 2, node[n / 2].val, node[n / 2].name);++cnt;strcat(ans, node[n / 2].name);if (cnt < 3) {strcat(ans, " ");}return node[n / 2].val;
}int main(void)
{int t;scanf("%d", &t);while (t--) {int s, m, d;scanf("%d%d%d", &s, &m, &d);ans[0] = '\0';for (int i = 0; i < s; ++i) {x[i].input();}cnt = 0;sort(x, x + s, cmp);int res = f(x, s);for (int i = 0; i < m; ++i) {y[i].input();}sort(y, y + m, cmp);res += f(y, m);for (int i = 0; i < d; ++i) {z[i].input();}sort(z, z + d, cmp);res += f(z, d);printf("%d %s\n", res, ans);}return 0;
}

H、May Day Holiday(ZOJ 3876)
这道题可以简化成已知2015年5月1号是周5,求其他年份的5月1号是周几。每过七天,周几就会重复,所以,经过的天数模上7就好了,这里需要注意,周日用0表示。因为还有通过2015年计算出来比2015年小的年份的5月1号的周几,所以,也可以通过减算出来。
一周只有七天,知道了周几,在来计算放几天假就很好计算了。

#include <cstdio>
#include <cstring>
#include <cstdlib>#include <iostream>
#include <algorithm>using namespace std;#define N 10100int week[N];int leap(int y)
{if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) {return 1;} else {return 0;}
}int workday(int x)
{x = (x + 7) % 7;if (x >= 1 && x <= 5) {return 1;} else {return 0;}
}int main(void)
{week[2015] = 5;for (int i = 2016; i < 10000; ++i) {int x = week[i - 1] + 365;if (leap(i)) {++x;}week[i] = x % 7;}for (int i = 2014; i >= 1928; --i) {int x = week[i + 1] + 7 - (365 + leap(i + 1)) % 7;week[i] = (x + 7) % 7;}int t;scanf("%d", &t);while (t--) {int year;scanf("%d", &year);int x = week[year];int ans = 0;if ((x >= 3 && x <= 6)) {ans = 5;}if (x == 2 || x == 0) {ans = 6;}if (x == 1) {ans = 9;}printf("%d\n", ans);}return 0;
}

J、Convert QWERTY to Dvorak(ZOJ 3878)
其实是一道很水的题,不过两种布局的键盘对应关系稍微有点扯淡。我是从键盘上一次按键得到的。

#include <cstdio>
#include <cstring>
#include <cstdlib>#include <iostream>
#include <algorithm>using namespace std;#define N 1000010char str[N];
char mp1[] = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>? ";
char mp2[] = "`1234567890[]',.pyfgcrl/=\\aoeuidhtns-;qjkxbmwvz~!@#$%^&*(){}\"<>PYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ ";int main(void)
{while (gets(str)) {int len = strlen(str);for (int i = 0; i < len; ++i) {int x = 0;for (x = 0; str[i] != mp1[x]; ++x) {;}printf("%c", mp2[x]);}printf("\n");}return 0;
}

L、Demacia of the Ancients(ZOJ 3880)
给定n个数,计算有多少个数比6000大就行了。

#include <stdio.h>#define N 1000int num[N];int main(void)
{int t;scanf("%d", &t);while (t--) {int n;scanf("%d", &n);int cnt = 0;for (int i = 0; i <n ;++i) {int x;scanf("%d", &x);if (x > 6000) {cnt++;}}printf("%d\n", cnt);}return 0;
}

2015年4月25日浙江省ACM比赛题解相关推荐

  1. 我来说说2015年8月25日锤子科技夏季手机发布会的内情

    我来说说2015年8月25日锤子科技夏季手机发布会的内情, 虽然我也没去现场,我也不是锤子科技的,我跟锤子科技的人也不熟.那算什么内情啊?好吧,改一下,我来瞎说一下2015锤子科技夏季手机发布会的内情 ...

  2. 传智播客 刘意_2015年Java基础视频-深入浅出精华版 笔记(2015年10月25日23:28:50)

    day01 win 7系统打开DOS有趣方法:按住shift+右键,单击"在此处打开命令窗口"(注意:在此处可以是任何的文件夹,不一定是桌面) 用DOS删除的文件不可以在回收站恢复 ...

  3. KMP算法(待优化)--2015年7月25日14:04:25V1.0版

    #include <iostream> #include <string> #include <cstring> using namespace std;void ...

  4. 简单的字谜游戏--可扩展--2015年7月25日14:58:00V1.1版

    1.string类find匹配法 #include <iostream> #include <string> #include <cstring> #include ...

  5. 2015年2月25日

    二叉树遍历的递归与非递归实现 本次测试实现了二叉树先序遍历的递归与非递归实现,并测试了其性能,测试结果如预先考虑的一致,就是非递归的性能要不递归的性能高. 同时也实现了二叉树的广度优先的遍历,通过qu ...

  6. 全国计算机四六级报名时间2015,2015年英语四六级口语考试报名时间:10月25日起...

    出国留学网英语栏目提示:2015年11月六级口语考试即将开始报名,请跟着小编一起阅读以下的口语考试相关事宜. 全国大学英语四.六级委员会办公室最新发布的<2015年11月全国大学英语四.六级口语 ...

  7. 面试经历---YY欢聚时代(2015年11月21日上午初试、25日下午复试)

    YY欢聚时代一年多前去面试过一次,当时鄙视了,在现在的公司呆了1年半了,感觉做得很不爽,而且薪资又不满意,所以想找个新工作,就想去YY面试. 下面将两次YY面试的经历写出来,包括一次初试和一次复试的面 ...

  8. linux运维实战练习-2015年9月13日-9月15日课程作业(练习)安排

    一.作业(练习)内容: 1.描述shell程序的运行原理(可附带必要的图形说明): 2.总结shell编程中所涉及到的所有知识点(如:变量.语法.命令状态等等等,要带图的哟): 3.总结课程所讲的所有 ...

  9. 八月25日8点半服务器维修,三国乱世8月25日合区维护公告

    <三国乱世>8月合区维护公告 尊敬的玩家: 为保证游戏质量,增加更多玩家之间交流和互动的机会,实现最激烈的国战和战斗氛围.我们将于2015年8月25日对<三国乱世>部分服务器进 ...

  10. 全球六大国际域名解析量统计报告(6月25日)

    IDC评述网(idcps.com)06月29日报道:根据DailyChanges公布的实时数据显示,在2015年6月25日,全球六大国际域名解析量总量持续攀升至153,246,819个,环比6月16日 ...

最新文章

  1. (error) ERR wrong number of arguments for 'hmget' command
  2. linux message日志只有4k,linux命令查看日志
  3. 嵌入式Linux应用开发完全手册 pdf 韦东山
  4. ckplayer php,ckplayer播放器
  5. JS调用Arcgis实现地图中心点画圆
  6. linux命令du -sh,du命令_Linux du 命令用法详解:显示每个文件和目录的磁盘使用空间...
  7. 坚果云网盘教你拥有这5个习惯 升职加薪不是梦
  8. 软件壳的概念和如何脱壳基础
  9. 程序员知识体系探索:点、线、面、体
  10. java buildpack是什么_javabuildpack改造
  11. mathtype导致无法粘贴解决方法
  12. 相信技术的力量 - RSAC 2020 (2)
  13. 【Codeforces 1038D】Slime
  14. MariaDB glare cluster简介
  15. 机器学习-3:MachineLN之dl
  16. python读取edi_对python .txt文件读取及数据处理方法总结
  17. 塑料高分子应用计算机,分子模拟方法与模拟软件Materials+Studio在高分子材料中的应用.pdf...
  18. Python与Ansys apdl有限元系列二:矩阵位移法计算桁架结构
  19. Eclipse Che的用户管理和权限
  20. 武汉大学测绘学院《导航学》课程复习资料

热门文章

  1. 北理大编程作业:确定母亲节
  2. 孤独剑客的推荐安全站点 (from http://bbs.isbase.net)
  3. 中国第一代***骄傲
  4. Windows Message ID
  5. lighttpd服务器404页修改,教你学会Lighttpd的安装配置
  6. 03.C 语言实现3.5寸虚拟软盘
  7. ArcGIS许可服务管理器无法启动问题
  8. 如何设计SEO关键字分析统计表
  9. 单日峰值2T发送量邮件营销平台实践经验
  10. Python入门-类的成员