口算训练

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <string>
  6. #include <map>
  7. #include <cmath>
  8. #include <vector>
  9.  
  10. #define Faster ios::sync_with_stdio(false),cin.tie(0)
  11. #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
  12. #define Close fclose(stdin),fclose(stdout)
  13. const int maxn = 1e5 + ;
  14. using namespace std;
  15. const int MOD = 1e9+;
  16. typedef long long ll;
  17.  
  18. vector<int> g[maxn];
  19. //下标肯定是从小到大按顺序的
  20.  
  21. void res(int id, int x){
  22. for(int i = ;i*i <= x;i++){
  23. while(x%i == ){
  24. g[i].push_back(id);
  25. x /= i;
  26. }
  27. }
  28. if(x > )
  29. g[x].push_back(id);
  30. }
  31.  
  32. int query(int l,int r, int x){
  33. return upper_bound(g[x].begin(), g[x].end(), r) - lower_bound(g[x].begin(),g[x].end(), l);
  34. }
  35.  
  36. void init(){
  37. for(int i = ;i < maxn;i++)
  38. g[i].clear();
  39. }
  40.  
  41. int main(){
  42. // Faster;
  43. int t;
  44. // cin >> t;
  45. scanf("%d", &t);
  46. while(t--){
  47. init();
  48. int n, q;
  49. scanf("%d%d", &n, &q);
  50. for(int i = ;i <= n;i++){
  51. int x;
  52. // cin >> x;
  53. scanf("%d", &x);
  54. res(i, x);
  55. }
  56. while(q--){
  57. int l, r, d, num;
  58. // cin >> l >> r >> d;
  59. scanf("%d%d%d", &l, &r, &d);
  60. bool ok = true;
  61. for(int i = ;i*i <= d;i++){
  62. int cnt = ;
  63. while(d%i == ){
  64. cnt++;
  65. d /= i;
  66. }
  67. //因子为i 的数目 大于(l,r)中i 的个数
  68. num = query(l, r, i);
  69. if(cnt > num){
  70. ok = false;
  71. break;
  72. }
  73. }
  74. if(ok && d > ){
  75. num = query(l, r, d);
  76. if(num == )
  77. ok = false;
  78. }
  79. if(ok)
  80. // cout << "Yes" << endl;
  81. printf("Yes\n");
  82. else
  83. // cout << "No" << endl;
  84. printf("No\n");
  85. }
  86. }
  87. return ;
  88. }

缺失的数据范围

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <string>
  6. #include <map>
  7. #include <cmath>
  8. #include <vector>
  9.  
  10. #define Faster ios::sync_with_stdio(false),cin.tie(0)
  11. #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
  12. #define Close fclose(stdin),fclose(stdout)
  13. const int maxn = 1e4 + ;
  14. using namespace std;
  15. const int MOD = 1e9+;
  16. typedef unsigned long long ll;
  17.  
  18. int a, b;
  19. ll k;
  20.  
  21. bool check(ll x){
  22. long double ans = ;
  23. for(int i = ;i < a;i++){
  24. ans *= x;
  25. if(ans > k)
  26. return false;
  27. }
  28. ll bb = ceil(log2(x));
  29. for(int i = ;i < b;i++){
  30. ans *= bb;
  31. if(ans > k)
  32. return false;
  33. }
  34. return true;
  35. }
  36.  
  37. int main(){
  38. Faster;
  39. int n;
  40. cin >> n;
  41. while(n--){
  42. cin >> a >> b >> k;
  43. ll l = ;
  44. ll r = k;
  45. while(l <= r){
  46. ll mid = (l+r)/;
  47. if(check(mid)){
  48. l = mid+;
  49. }
  50. else{
  51. r = mid-;
  52. }
  53. }
  54. cout << r << endl;
  55. }
  56. return ;
  57. }

赛题分析

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <string>
  6. #include <map>
  7. #include <cmath>
  8. #include <vector>
  9.  
  10. #define Faster ios::sync_with_stdio(false),cin.tie(0)
  11. #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
  12. #define Close fclose(stdin),fclose(stdout)
  13. const int maxn = 1e4 + ;
  14. using namespace std;
  15. const int MOD = 1e9+;
  16. typedef long long ll;
  17.  
  18. #define INF 0xfffffff
  19.  
  20. int main(){
  21. Faster;
  22. int t;
  23. cin >> t;
  24. int cnt = ;
  25. while(t--){
  26. int n, m;
  27. cin >> n >> m;
  28. int Min1 = INF;
  29. int Min2 = INF;
  30. for(int i = ;i < n;i++){
  31. int x;
  32. cin >> x;
  33. if(x < Min1){
  34. Min1 = x;
  35. }
  36. }
  37. for(int i = ;i < m;i++){
  38. int x;
  39. cin >> x;
  40. if(x < Min2){
  41. Min2 = x;
  42. }
  43. }
  44. cout << "Problem " << ++cnt << ":" << endl;
  45. cout << "Shortest judge solution: " << Min1 << " bytes." << endl;
  46. if(Min2 == INF)
  47. cout << "Shortest team solution: N/A bytes." << endl;
  48. else
  49. cout << "Shortest team solution: " << Min2 << " bytes." << endl;
  50. }
  51. return ;
  52. }

SA-IS后缀数组

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstring>
  4. #include <cstdio>
  5. #include <string>
  6. #include <map>
  7. #include <cmath>
  8. #include <vector>
  9.  
  10. #define Faster ios::sync_with_stdio(false),cin.tie(0)
  11. #define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
  12. #define Close fclose(stdin),fclose(stdout)
  13. const int maxn = 1e4 + ;
  14. using namespace std;
  15. const int MOD = 1e9+;
  16. typedef long long ll;
  17.  
  18. int main(){
  19. Faster;
  20. int t;
  21. cin >> t;
  22. while(t--){
  23. int n;
  24. cin >> n;
  25. string s;
  26. cin >> s;
  27. int cnt = ;
  28. for(int i = ;i < n-;i++){
  29. if(s[i] == s[i+]){
  30. cnt++;
  31. }
  32. else if(s[i] < s[i+]){
  33. cnt++;
  34. while(cnt){
  35. cnt--;
  36. cout << "<";
  37. }
  38. }
  39. else if(s[i] > s[i+]){
  40. cnt++;
  41. while(cnt){
  42. cnt--;
  43. cout << ">";
  44. }
  45. }
  46. }
  47. while(cnt--){
  48. cout << ">";
  49. }
  50. cout << endl;
  51. }
  52. return ;
  53. }

"字节跳动杯"2018中国大学生程序设计竞赛-女生专场的更多相关文章

  1. "字节跳动杯"2018中国大学生程序设计竞赛-女生专场 Solution

    A - 口算训练 题意:询问 $[L, R]$区间内 的所有数的乘积是否是D的倍数 思路:考虑分解质因数 显然,一个数$x > \sqrt{x} 的质因子只有一个$ 那么我们考虑将小于$\sqr ...

  2. 2017中国大学生程序设计竞赛 - 女生专场 Deleting Edges(思维+最短路)

    Deleting Edges Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  3. 2017中国大学生程序设计竞赛 - 女生专场 Happy Necklace(递推+矩阵快速幂)

    Happy Necklace Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  4. 2017中国大学生程序设计竞赛 - 女生专场(Graph Theory)

    Graph Theory Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)To ...

  5. 2017中国大学生程序设计竞赛 - 女生专场(dp)

    Building Shops Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) To ...

  6. "巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场

    Combine String #include<cstdio> #include<cstring> #include<iostream> #include<a ...

  7. hdu_5705_Clock("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5705 题意:给你一个时间和一个角度,问你下一个时针和分针形成给出的角度是什么时候 题解:我们可以将这个 ...

  8. hdu_5707_Combine String("巴卡斯杯" 中国大学生程序设计竞赛 - 女生专场)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5707 题意:给你三个字符串 a,b,c,问你 c能否拆成a,b,a,b串的每一个字符在c中不能变 题解 ...

  9. HDU 6024(中国大学生程序设计竞赛女生专场1002)

    这是CCPC女生专场的一道dp题.大佬们都说它简单,我并没有感到它有多简单. 先说一下题意:在一条直线上,有n个教室,现在我要在这些教室里从左到右地建设一些作为糖果屋,每个教室都有自己的坐标xi 和建 ...

随机推荐

  1. HDU4965 Fast Matrix Calculation —— 矩阵乘法、快速幂

    题目链接:https://vjudge.net/problem/HDU-4965 Fast Matrix Calculation Time Limit: 2000/1000 MS (Java/Othe ...

  2. Nginx安装教程(Centos6.8)

    1.安装gcc gcc-c++(如新环境,未安装请先安装 yum install -y gcc gcc-c++ 2.安装wget yum -y install wget 3.安装PCRE库 cd /h ...

  3. rc.local 开启自启动,检测是否成功

    rc.local /etc/init.d/nginx start 查看运行状态 systemctl status rc-local ● rc-local.service - /etc/rc.local ...

  4. Swing项目编译成exe,并且打包成安装文件(二)

    前面我们讲到了将Swing项目编译成双击可执行的文件exe,这篇我就教大家怎么把exe打包成需要在电脑安装的那种,首先需要一个工具,Inno Setup 编译器, 下载地址,我这个是汉化版的,双击打开 ...

  5. python学习笔记:第二天(运算符)

    Python3 运算符 注:以下部分示例源自于http://www.runoob.com/ 1.算术运算符 假设变量a为10,变量b为20: 运算符 描述 实例 + 加 - 两个对象相加 a + b ...

  6. YCSB-mapkeer-leveldb实测

    使用thrift0.8.0编译好java版的mapkeeper并安装到ycsb下,使用thrift0.9.2编译好c++版的mapkeeper并编译leveldb客户端运行. 测试成功.recordc ...

  7. hdu-5747 Aaronson(水题)

    题目链接: Aaronson Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others ...

  8. 杂文笔记《Redis在万亿级日访问量下的中断优化》

    杂文笔记<Redis在万亿级日访问量下的中断优化> Redis在万亿级日访问量下的中断优化 https://mp.weixin.qq.com/s?__biz=MjM5ODI5Njc2MA= ...

  9. 杂项:UI

    ylbtech-杂项:UI 1.返回顶部 1. UI即User Interface(用户界面)的简称.泛指用户的操作界面,包含移动APP,网页,智能穿戴设备等.UI设计主要指界面的样式,美观程度.而使 ...

  10. final/finalize/finally的区别

    一.性质不同 (1)final为关键字: (2)finalize()为方法:---垃圾回收机制中的方法(GC) (3)finally为为区块标志,用于try语句中: 二.作用 (1)final为用于标 ...