题解报告(CDUT暑期集训——第一场)


A - Maximum Multiple

HDU - 6298

  • 思路:先按照题意打表 发现规律 就出来了(最开始没开long long贡献了3发 然后又忘了换行又贡献了一发

  • AC代码


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;ll Pow(ll a, ll b, ll c){ll ans = 1;a %= c;while (b){if (b & 1) ans = (ans * a) % c;a = (a * a) % c;b >>= 1;}return (ans % c);
}bool cmp(const int &a, const int &b){return a < b;
}ll gcd(ll x, ll y){return x % y == 0 ? y : gcd(y, x % y);
}ll lcm(ll x, ll y){return x / gcd(x, y) * y;
}const int MAXN = 2000 + 5;
const int mod = 1e9 + 7;
ll comb[MAXN][MAXN];void init(){for (int i = 0; i < MAXN; i ++ ){comb[i][0] = comb[i][i] = 1;for (int j = 1; j < i; j ++ ){comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];comb[i][j] %= mod;}}
}ll mult_mod(ll a, ll b, ll c){a %= c;b %= c;ll res = 0;while (b){if (b & 1){res += a;res %= c;}a <<= 1;a %= c;b >>= 1;}return res;
}int main(){ll t;scanf("%lld", &t);ll n;while (t--){scanf("%lld", &n);if (n % 12 == 1 || n % 12 == 2 || n % 12 == 5 || n % 12 == 7 || n % 12 == 10 || n % 12 == 11) printf("-1\n");else{if (n % 3) printf("%lld", (n / 4) * (n / 4) * (n / 4) * 2);else printf("%lld", (n / 3) * (n / 3) * (n / 3));}}return 0;
}

B - Balanced Sequence

HDU - 6299

  • 思路:贪心 先把每个串里面的括号匹配之后去掉 再对它们排序 匹配剩下的括号就行了(开始莫名其妙MLE了九发 找不到原因 然后再交TLE RE 后面发现cmp写错了 改了之后就过了

  • AC代码


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<string.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;const int N = 100010;int n, t, ans, cnt_l;
char c[N];struct st{int l;int r;
}s[N];bool cmp(st a, st b){if (a.l > a.r && b.l <= b.r) return true;else if (a.l <= a.r && b.l > b.r) return false;else if (a.l > a.r && b.l > b.r) return a.r < b.r;else return a.l > b.l;
}int main(){scanf("%d", &t);while (t --){ans = 0;cnt_l = 0;scanf("%d", &n);for (int i = 1; i <= n; i ++ ){s[i].l = 0;s[i].r = 0;scanf("%s", c);for (int j = 0; j < strlen(c); j ++ ){if (c[j] == '(') s[i].l ++;if (c[j] == ')') s[i].l == 0 ? s[i].r ++ : (s[i].l -= 1, ans += 2);}}sort(s + 1, s + n + 1, cmp);for (int i = 1; i <= n; i ++ ){if (s[i].r > cnt_l) s[i].r = cnt_l;ans += 2 * s[i].r;cnt_l += s[i].l - s[i].r;}printf("%d\n", ans);}return 0;
}

C - Triangle Partition

HDU - 6300

  • 思路:贪心 写个struct对x排个序就出来了(

  • AC代码


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;ll Pow(ll a, ll b, ll c){ll ans = 1;a %= c;while (b){if (b & 1) ans = (ans * a) % c;a = (a * a) % c;b >>= 1;}return (ans % c);
}//bool cmp(const int &a, const int &b){
//    return a < b;
//}ll gcd(ll x, ll y){return x % y == 0 ? y : gcd(y, x % y);
}ll lcm(ll x, ll y){return x / gcd(x, y) * y;
}const int MAXN = 2000 + 5;
const int mod = 1e9 + 7;
ll comb[MAXN][MAXN];void init(){for (int i = 0; i < MAXN; i ++ ){comb[i][0] = comb[i][i] = 1;for (int j = 1; j < i; j ++ ){comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];comb[i][j] %= mod;}}
}ll mult_mod(ll a, ll b, ll c){a %= c;b %= c;ll res = 0;while (b){if (b & 1){res += a;res %= c;}a <<= 1;a %= c;b >>= 1;}return res;
}const int N = 1010;struct point{int x, y;int index;
}p[N];bool cmp(point a, point b){if (a.x == b.x) return a.y < b.y;return a.x < b.x;
}int main(){int t;scanf("%d", &t);int n;while (t--){scanf("%d", &n);for (int i = 1; i <= 3 * n; i ++ ){scanf("%d%d", &p[i].x, &p[i].y);p[i].index = i;}sort(p + 1, p + 3 * n + 1, cmp);for (int i = 1; i <= n; i ++ )printf("%d %d %d\n", p[(i - 1) * 3 + 1].index, p[(i - 1) * 3 + 2].index, p[(i - 1) * 3 + 3].index);}return 0;
}

D - Distinct Values

HDU - 6301

  • 思路:贪心 先排序 后用set维护就行了(学到了一个新东西 迭代器赋值前要加* 要不然会报错

  • AC代码


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;ll Pow_mod(ll a, ll b, ll c){ll ans = 1;a %= c;while (b){if (b & 1) ans = (ans * a) % c;a = (a * a) % c;b >>= 1;}return (ans % c);
}const int N = 1000010;int t, n, m, L, R;
set<int> st;
int ans[N];struct node{int l, r;
}interval[N];int cmp(node a, node b){return a.l == b.l ? a.r < b.r : a.l < b.l;
}int main(){scanf("%d", &t);while (t -- ){st.clear();scanf("%d%d", &n, &m);for (int i = 1; i <= m; i ++ )scanf("%d%d", &interval[i].l, &interval[i].r);sort(interval + 1, interval + m + 1, cmp);L = interval[1].l;R = interval[1].r;for (int i = 1; i <= n; i ++ ){st.insert(i);ans[i] = 1;}for (int i = L; i <= R; i ++ ){ans[i] = *st.begin();st.erase(st.begin());}for (int i = 2; i <= m; i ++ ){while (L < interval[i].l){st.insert(ans[L]);L ++;}while (R < interval[i].r){if (R < interval[i].l - 1) R ++;else{R ++;ans[R] = *st.begin();st.erase(st.begin());}}}for (int i = 1; i < n; i ++ ) printf("%d ", ans[i]);printf("%d\n", ans[n]);}
}

G - Chiaki Sequence Revisited

HDU - 6304

  • 思路:先打表 找规律 令f(i)为i出现的次数 再打表 去掉a1 = 1出现的一次 可以得到f(2 * i) = f(i) + 1 f(2 * i + 1) = 1 当时到了这里就卡死了 卡了两个半小时 然后想着把f(i) = n, n = 1, 2, 3, ...打印出来看下 结果一打印就发现了f(i)相同的构成了一个首项为2^(n-1) 公差为2^n的等差数列 就直接根据公式就解出来了 结束前没能写出来 结束之后几分钟写好交了三发才过 第一发用自己写的乘法取膜函数tle了 第二发有一处忘了取膜贡献了一发wa 第三发才终于过了

  • AC代码


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;ll Pow_mod(ll a, ll b, ll c){ll ans = 1;a %= c;while (b){if (b & 1) ans = (ans * a) % c;a = (a * a) % c;b >>= 1;}return (ans % c);
}ll Pow(ll a, ll b){ll ans = 1;while (b){if (b & 1) ans *= a;a *= a;b >>= 1;}return ans;
}bool cmp(const int &a, const int &b){return a < b;
}ll gcd(ll x, ll y){return x % y == 0 ? y : gcd(y, x % y);
}ll lcm(ll x, ll y){return x / gcd(x, y) * y;
}const int MAXN = 2000 + 5;
const int mod = 1e9 + 7;
ll comb[MAXN][MAXN];void init(){for (int i = 0; i < MAXN; i ++ ){comb[i][0] = comb[i][i] = 1;for (int j = 1; j < i; j ++ ){comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];comb[i][j] %= mod;}}
}ll mult_mod(ll a, ll b, ll c){a %= c;b %= c;ll res = 0;while (b){if (b & 1){res += a;res %= c;}a <<= 1;a %= c;b >>= 1;}return res;
}const int N = 63;ll s[N], t[N];ll calc(ll n){ll tmp = 0;if (n == 1) return 1;n -= 1;for (int i = N - 1; i >= 0; i -- ){while (s[i] <= n){n -= s[i];tmp += t[i];}}return tmp;
}ll get_pos(ll n){ll pos = 0;if (n == 1) return 1;n -= 1;for (int i = N - 1; i >= 0; i -- ){while (t[i] <= n){n -= t[i];pos += s[i];}}return pos + 1;
}int main(){s[0] = 1;t[0] = 1;for (int i = 1; i < N; i++){s[i] = s[i - 1] * 2 + 1;t[i] = t[i - 1] * 2;}int T;scanf("%d", &T);ll n;while (T--){scanf("%lld", &n);ll tmp = calc(n);ll cnt = n - get_pos(tmp);ll sum = 0;for (int i = 1; t[i - 1] <= tmp; i ++ ){ll b1 = t[i - 1];ll d = t[i];ll n_ = (tmp - b1) / d;if ((tmp - b1) % d) n_ += 1;ll bn = b1 + (n_ - 1) * d;ll sum_b = (b1 % mod + bn % mod) * (n_ % mod) * 500000004 % mod;sum += i * sum_b % mod;sum %= mod;if (!((tmp - b1) % d)) sum += (cnt % mod) * (tmp % mod) % mod;sum %= mod;}printf("%lld\n", sum + 1);}return 0;
}

K - Time Zone

HDU - 6308

  • 思路:数学题 把时区差换算成时间差(分钟) 然后换算过去就行了 最开始写了个贼蠢的模拟 写的很长 还wa了 后面才想起来没写%02d才wa的

  • AC代码


#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;ll Pow(ll a, ll b, ll c){ll ans = 1;a %= c;while (b){if (b & 1) ans = (ans * a) % c;a = (a * a) % c;b >>= 1;}return (ans % c);
}bool cmp(const int &a, const int &b){return a < b;
}ll gcd(ll x, ll y){return x % y == 0 ? y : gcd(y, x % y);
}ll lcm(ll x, ll y){return x / gcd(x, y) * y;
}const int MAXN = 2000 + 5;
const int mod = 1e9 + 7;
ll comb[MAXN][MAXN];void init(){for (int i = 0; i < MAXN; i ++ ){comb[i][0] = comb[i][i] = 1;for (int j = 1; j < i; j ++ ){comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];comb[i][j] %= mod;}}
}ll mult_mod(ll a, ll b, ll c){a %= c;b %= c;ll res = 0;while (b){if (b & 1){res += a;res %= c;}a <<= 1;a %= c;b >>= 1;}return res;
}int main(){int t;scanf("%d", &t);int a, b;while (t--){char flag;double utc;scanf("%d %d UTC%c%lf", &a, &b, &flag, &utc);int tmp = (int)(utc * 10 + 0.1);if (flag == '-') tmp = -tmp;int sum = a * 60 + b + (tmp * 6 - 8 * 60);sum %= (24 * 60);if (sum < 0) sum += (24 * 60);printf("%02d:%02d\n", sum / 60, sum % 60);}return 0;
}

转载于:https://www.cnblogs.com/Misuchii/p/11211178.html

题解报告(CDUT暑期集训——第一场)相关推荐

  1. 题解报告(CDUT暑期集训——第二场)

    题解报告(CDUT暑期集训--第二场) D - Game HDU - 6312 思路:水题 Alice一直是必胜态 AC代码 #include<stdio.h> #include<i ...

  2. 题解报告(CDUT暑期集训——第三场)

    题解报告(CDUT暑期集训--第三场) A - Problem A. Ascending Rating HDU - 6319 思路:单调队列板子题?(但是弱的一批的我还是不会用(有空补上 用的滑动窗口 ...

  3. 题解报告(CDUT暑期集训——第四场)

    题解报告(CDUT暑期集训--第四场) Problem D. Nothing is Impossible HDU - 6335 思路:水题 排个序循环判断就出来了 AC代码 #include<s ...

  4. 题解报告(CDUT暑期集训——第六场)

    题解报告(CDUT暑期集训--第六场) A - oval-and-rectangle HDU - 6362 思路:水题 积分一化就出来了 AC代码 #include<stdio.h> #i ...

  5. 题解报告(CDUT暑期集训——第五场)

    题解报告(CDUT暑期集训--第五场) B - Beautiful Now HDU - 6351 思路:直接暴力全排列就行了 最多\(10!\)次 题目限制2500ms 全排列大概是2000多ms(最 ...

  6. 【暑期集训第一周:搜索】【DFSBFS】

    文章目录 一.深度优先搜索(DFS) 1.1 全排列问题 1.1.1 问题描述 输入格式 输出格式 样例 #1 样例输入 #1 样例输出 #1 1.1.2 思路表示 1.1.3 代码 二.广度优先搜索 ...

  7. HDU 2019 Multi-University Training Contest 1 杭电2019多校联合训练赛 第一场 1001 Blank (6578)

    HDU 2019 Multi-University Training Contest 1 杭电2019暑期多校集训第一场 1001 Blank (6578) Problem Description T ...

  8. 暑期集训1:C++STL 例1:UVA-10815

    2018学校暑期集训第一天--C++与STL 例一  --  UVA - 10815 Andy's First Dictionary Description XY学长刚刚立下了再不过CET就直播xx的 ...

  9. 暑期集训1:C++STL 练习题E:POJ-2431

    2018学校暑期集训第一天--C++与STL 练习题E --  POJ - 2431 E - 二律背反的对偶 A group of cows grabbed a truck and ventured ...

最新文章

  1. javascript中将整数添加千位符号
  2. java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.LoopTag 错误
  3. 【跃迁之路】【685天】程序员高效学习方法论探索系列(实验阶段442-2019.1.4)...
  4. python arcgis批量绘图_python调用ArcGIS批量生成多环缓冲区(多边形等距离放大)...
  5. DOS 网络命令之 ipconfig
  6. android 6.0版本名字,棉花糖Marshmallow 是Android 6.0的名字
  7. 年底了,小心这些现象。别再无动于衷
  8. 闪光灯slave是什么意思_闪光灯实战讲解 | 室内光线+闪光灯使用配合=完美光效...
  9. libjpeg学习3:turbojpeg试用
  10. libcurl 遇到的问题
  11. 2008年信息安全服务市场发展报告
  12. xampp 2016支持php7.0,xampp 装php7
  13. java短信_java发送短信的实现步骤
  14. 程序员英语学习指南(建议收藏)
  15. 什么是人工智能(AI)数据平台?
  16. 程序化生成(PCG)算法的改进——基于以地学为主的多基础学科
  17. web前端开发技术实验与实践(第三版)储久良编著 项目6 文本与段落标记的应用
  18. nginx 安装到Java代码上传图片利用ftp过程遇到的问题总结
  19. 《腾讯之道》读书笔记
  20. 百度地图加载过慢问题

热门文章

  1. 牛客竞赛每日俩题 - Day4
  2. go语言制作gif动画
  3. Word 查找替换,通配符一览表
  4. win10 “你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问。解决方案(实测有效)
  5. ArcGIS Server 10.6(Windows)离线许可授权操作
  6. keil出现大量未知语法错误(系统移植)
  7. echarts gallery新地址!!!
  8. ChatGPT正当时,让我们一起深耕智能内容生成和智能内容增强领域
  9. 2023年CDGA考试模拟题库(701-800)
  10. Citrix Server 添加本地磁盘