A - Acperience

HDU - 5734

题意:

给你一个加权向量,需要我们找到一个二进制向量和一个比例因子α,使得|W-αB|的平方最小,而B的取值为+1,-1,我们首先可以想到α为输入数据的平均值,考虑到是平方和,然后化简表达式,可以得到一个化简的式子,用n通分,可以做到没有除法,然后分子分母化简到互质。

  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<iomanip>
  5. #include<algorithm>
  6. #include<iostream>
  7. #include<string>
  8. #include<cstring>
  9. #include<vector>
  10. #include<stack>
  11. #include<bitset>
  12. #include<cstdlib>
  13. #include<cmath>
  14. #include<set>
  15. #include<list>
  16. #include<deque>
  17. #include<map>
  18. #include<queue>
  19. using namespace std;
  20. typedef long long ll;
  21. const double PI = acos(-1.0);
  22. const double eps = 1e-6;
  23. const int INF = 0x3f3f3f3f;
  24. ll gcd(ll a, ll b) {
  25. return a % b == 0 ? b : gcd(b, a%b);
  26. }
  27. int main()
  28. {
  29. ll n;
  30. int kase;
  31. ll sum, sum2;
  32. while (~scanf("%d", &kase))
  33. {
  34. while (kase--)
  35. {
  36. scanf("%lld", &n);
  37. sum = 0;
  38. sum2 = 0;
  39. int num;
  40. for (int i = 0; i < n; i++) {
  41. scanf("%d", &num);
  42. sum += abs(num);
  43. sum2 += num * num;
  44. }
  45. ll a = n * sum2 - sum*sum;
  46. ll ans = gcd(a, n);
  47. //cout << a / ans << " " << n / ans << endl;
  48. printf("%lld/%lld\n", a/ans,n/ans);
  49. }
  50. }
  51. return 0;
  52. }

E - Eureka

HDU - 5738

题意:

由题目中的不等式可以分析得到,对于共线的点可以在一个集合中,于是这个问题转化为在全集中划分共线的点的集合,最后用组合数学求数量。这样就可以解决这个问题。

接下来的问题是如果求得在一个点的集合数量,可以从一个点出发,处理其他啊全部的点,下一次去掉这个点,O(n*n)处理,这样考虑这个点与其它点的向量关系,可以用map保存每种向量的数量,这里特殊处理一下,在点的重载减法里面处理。即在这条直线上的点的数目,对于重复的点也需要保存一下,组合数计数加进去。

这个题还有一点处理:对这种方法,从一点个出发,我在计数时候一定取这个点,这样虽然处理的直线会有重复,但是我的计数没有重复,所以这个的处理并不是一次计算一条线段上面的全部集合数量。

  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<iostream>
  3. #include<algorithm>
  4. #include<string>
  5. #include<string.h>
  6. #include<stdio.h>
  7. #include<string.h>
  8. #include<algorithm>
  9. #include<map>
  10. typedef long long ll;
  11. using namespace std;
  12. struct node
  13. {
  14. int x, y;
  15. bool operator<(const node& p)const {
  16. if (x != p.x)return x < p.x;
  17. return y < p.y;
  18. }
  19. bool operator== (const node& p)const {
  20. if (x == p.x&&y == p.y)return true;
  21. return false;
  22. }
  23. };
  24. int gcd(int x, int y)
  25. {
  26. if (x == 0)return y;
  27. else return gcd(y%x, x);
  28. }
  29. node operator-(node a, node b) {
  30. node temp;
  31. temp.x = a.x - b.x; temp.y = a.y - b.y;
  32. if (temp.x != 0 || temp.y != 0) {
  33. int ans = gcd(temp.x, temp.y);
  34. if (ans != 0) { temp.x /= ans; temp.y /= ans; }
  35. }
  36. if (temp.x == 0)temp.y = abs(temp.y);
  37. else if (temp.x < 0) {
  38. temp.x = -temp.x;
  39. temp.y = -temp.y;
  40. }
  41. return temp;
  42. }
  43. const int maxn = 1001;
  44. node no[maxn];
  45. map<node, int>::iterator it;
  46. typedef long long ll;
  47. const int mod = 1e9 + 7;
  48. ll num[maxn];
  49. ll ans;
  50. int main() {
  51. int T;
  52. num[0] = 1;
  53. for (int i = 1; i<maxn; i++)
  54. {
  55. num[i] = num[i - 1] * 2;
  56. num[i] %= mod;
  57. }
  58. scanf("%d", &T);
  59. while (T--) {
  60. int n;
  61. ans = 0;
  62. scanf("%d", &n);
  63. for (int i = 0; i < n; i++) {
  64. scanf("%d%d", &no[i].x, &no[i].y);
  65. }
  66. for (int i = 0; i < n; i++) {
  67. map<node, int>p;
  68. int len = 1;
  69. for (int j = i + 1; j < n; j++) {
  70. if (no[i] == no[j]) {
  71. len++;
  72. continue;
  73. }
  74. node temp = no[i] - no[j];
  75. p[temp]++;
  76. }
  77. //len-1是保证处理的这个点加入集合
  78. if (len > 1)
  79. {
  80. ans += num[len - 1] - 1;
  81. ans %= mod;
  82. }
  83. for (it = p.begin(); it != p.end(); it++) {
  84. int m = it->second;
  85. //num[n]-1是保证在外面至少取一个点。
  86. ans = ans+((ll)num[len - 1])*((ll)num[m] - 1);
  87. ans = ans % mod;
  88. }
  89. }
  90. printf("%I64d\n", ans);
  91. }
  92. }

I - It's All In The Mind

HDU - 5742

题意:

求一个分式的最大值,即保存前两个最大(a1,a2),后面最小(a3 a4 a5....),可以保证题目最优答案。由于非递增型,对第一第二的数据特殊处理,a3及其以后,保证ak前面的等于ak即可,这样保证最小。

队友的这种处理,还是很方便a2 = min(a1, a2);,不需要特殊处理,写出来就AC了。

  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<iomanip>
  5. #include<algorithm>
  6. #include<iostream>
  7. #include<string>
  8. #include<cstring>
  9. #include<vector>
  10. #include<stack>
  11. #include<bitset>
  12. #include<cstdlib>
  13. #include<cmath>
  14. #include<set>
  15. #include<list>
  16. #include<deque>
  17. #include<map>
  18. #include<queue>
  19. using namespace std;
  20. typedef long long ll;
  21. const double PI = acos(-1.0);
  22. const double eps = 1e-6;
  23. const int INF = 0x3f3f3f3f;
  24. int gcd(int a, int b)
  25. {
  26. return a % b == 0 ? b : gcd(b, a % b);
  27. }
  28. int main()
  29. {
  30. ll n,m;
  31. int kase;
  32. ll sum, sum2;
  33. int num;
  34. while (~scanf("%d", &kase))
  35. {
  36. int x, y;
  37. int a1,a2, b;
  38. while (kase--)
  39. {
  40. a1 =100,a2=100;
  41. b = 0;
  42. scanf("%lld%lld", &n,&m);
  43. int j = 1;
  44. bool flag = 0;
  45. for (int i = 1; i <= m; i++) {
  46. scanf("%d%d", &x, &y);
  47. if (x == 1) {
  48. a1 = y;
  49. }
  50. else if (x == 2) {
  51. a2 = y;
  52. }
  53. else {
  54. if (j < 3)j = 3;
  55. for (j; j <= x; j++)
  56. b += y;
  57. }
  58. }
  59. a2 = min(a1, a2);
  60. b += (a1+a2);
  61. int ans = gcd(a1+a2, b);
  62. cout << (a1+a2)/ ans << "/" << b / ans << endl;
  63. }
  64. }
  65. return 0;
  66. }

K - Keep On Movin

HDU - 5744

题意:

maximize the length of the shortest palindromic string

保证的是每一个字符串都是回文的,对于偶数的字母类型,可以保证,加入任何回文串,对于奇数的字母类型,可以把其中的偶数的个数减掉,最后保留的是1,其它的看成偶数的字母类型,加入到偶数的类型中。

一个技巧,把每两个字母看成一个组,这个不需要考虑字母的组数,直接用除法平均分配就好了。

  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<iomanip>
  5. #include<algorithm>
  6. #include<iostream>
  7. #include<string>
  8. #include<cstring>
  9. #include<vector>
  10. #include<stack>
  11. #include<bitset>
  12. #include<cstdlib>
  13. #include<cmath>
  14. #include<set>
  15. #include<list>
  16. #include<deque>
  17. #include<map>
  18. #include<queue>
  19. using namespace std;
  20. typedef long long ll;
  21. const double PI = acos(-1.0);
  22. const double eps = 1e-6;
  23. const int INF = 0x3f3f3f3f;
  24. int gcd(int a, int b)
  25. {
  26. return a % b == 0 ? b : gcd(b, a % b);
  27. }
  28. int main()
  29. {
  30. ll n;
  31. int kase;
  32. ll sum, sum2;
  33. int num;
  34. while (~scanf("%d", &kase))
  35. {
  36. while (kase--)
  37. {
  38. sum = 0;
  39. int k = 0;
  40. scanf("%lld", &n);
  41. for (int i = 0; i < n; i++)
  42. {
  43. scanf("%d", &num);
  44. if(num & 1)
  45. {k++;
  46. sum += num - 1;
  47. }
  48. else sum += num;
  49. }
  50. sum = sum / 2;
  51. if(k>0)cout << sum/k*2+1<<endl;
  52. else cout << sum*2 << endl;
  53. }
  54. }
  55. return 0;
  56. }

L - La Vie en rose

HDU - 5745

题解连接

DP还不行,嘤嘤嘤......

2016 Multi-University Training Contest 2题解报告的更多相关文章

  1. 2016 Al-Baath University Training Camp Contest-1

    2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...

  2. 2016 Multi-University Training Contest 6 题解

    我只能说: A Boring Question 下面公式重复了一行 \[ \sum\_{0\leq k\_{1},k\_{2},\cdots k\_{m}\leq n}\prod\_{1\leq j& ...

  3. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  4. 2016 Al-Baath University Training Camp Contest-1 F

    Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...

  5. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  6. 2015 Multi-University Training Contest 1 题解&&总结

    ---------- HDU 5288 OO’s Sequence 题意 给定一个数列(长度<$10^5$),求有多少区间[l,r],且区间内有多少数,满足区间内其它数不是他的约数. 数的范围$ ...

  7. 2015 Multi-University Training Contest 1 题解 BY FZUw

    题目链接:5288-5299 HDU5288 题解原文链接:我是链接

  8. 2016 Al-Baath University Training Camp Contest-1 I. March Rain —— 二分

    题目链接:http://codeforces.com/problemset/gymProblem/101028/I I. March Rain time limit per test 2 second ...

  9. AtCoder Beginner Contest 151 题解报告

    总的来说,这次的题目比较水,然而菜菜的我并没有把所有题目都做完,话不多说,直接来干货: A:Next Alphabet 题目链接:https://atcoder.jp/contests/abc151/ ...

随机推荐

  1. 关于expect的实战总结

    如何从机器A上ssh到机器B上,然后执行机器B上的命令?如何使之自动化完成?看完下面的文章你就明白了 一.安装 expect 是基于tcl 演变而来的,所以很多语法和tcl 类似 sudo apt-g ...

  2. 【WCF】解析WCF服务的搭建

    WCF是.NET提供的一种服务,可以将自己写的程序(完成特定功能,比如从数据库中读取数据操作等)分装成服务以后,发布到服务器上.然后会生成一个网址,客户端在编程的时候,可以引用这个服务,使用这个服务中 ...

  3. 构建自己的 Smart Life 私有云(一)-> 破解涂鸦智能插座

    博客搬迁至https://blog.wangjiegulu.com RSS订阅:https://blog.wangjiegulu.com/feed.xml 原文链接:https://blog.wang ...

  4. BizTalk RosettaNet 开发笔记

    RNIF BAM Tracking Error  解决办法:  503: Service Unavailable   解决办法:IIS 应用程序池运行账户用户名或密码错误,用户名不能是doma ...

  5. 那些好用的Chrome 插件

    1. json-viewer 推荐理由:一款Chrome浏览器查看JSON数据自动格式化显示的浏览器插件 https://github.com/tulios/json-viewer

  6. 基于Python37配置图片文字识别

    以管理员权限打开cmd控制台. 1.如何安装PIL 输入下面命令:pip install Pillow 参考:https://www.cnblogs.com/mrgavin/p/8177841.htm ...

  7. Gitee vs插件(Gitee Extension for Visual Studio)

    Gitee 码云(gitee.com)是开源中国推出的代码托管平台,支持 Git 和 SVN,提供免费的私有仓库托管. https://gitee.com/GitGroup/Gitee.VisualS ...

  8. 根据IP查地理位置信息

    IP地址库下载地址: https://www.ipip.net/product/ip.html 使用方式(Python): https://github.com/ipipdotnet/datx-pyt ...

  9. new和delete操作符

    C 语言中提供了 malloc 和 free 两个系统函数, 完成对堆内存的申请和释放.而 C++则提供了两个操作符 new 和 delete. 1. newnew 分配内存空间时,  分配内存空间大 ...

  10. ubuntu如何安装或更换内核

    内核是一个系统的灵魂,系统在启动的时候,就是基于相关的内核启动该系统的.我们怎么样更改ubuntu系统的内核并运行它呢? ubuntu18.04LTS 互联网安装内核. 安装内核的步骤非常简单,我们可 ...