A

模拟题

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int maxn = ;
  17. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  18. const int turn2[][] = {{, }, { -, }, {, }, {, -}, {, -}, { -, -}, {, }, { -, }};
  19. //priority_queue<int, vector<int>, less<int>> que;
  20. //next_permutation
  21. int main()
  22. {
  23. double h, m, C;
  24. cin >> h >> m;
  25. int H, D, N;
  26. cin >> H >> D >> C >> N;
  27. double ans = ;
  28. double duce = ;
  29. if (h < )
  30. {
  31. duce = 1.0 * ( - h) * - m;
  32. }
  33. else
  34. {
  35. C = 0.8 * C;
  36. }
  37. int need = H / N + ( - (H % N == ));
  38. double ans1 = 1.0 * need * C;
  39. if (duce != )
  40. {
  41. H += D * duce;
  42. C = 0.8 * C;
  43. need = H / N + ( - (H % N == ));
  44. ans = need * C;
  45. printf("%.4f\n", min(ans, ans1));
  46. }
  47. else
  48. {
  49. printf("%.4f\n", ans1);
  50. }
  51. }

B

阅读理解

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. const double EPS = 1.0e-4;
  12. typedef pair<int, int> pairint;
  13. typedef long long ll;
  14. typedef unsigned long long ull;
  15. //const int maxn = 3e5 + 10;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. //priority_queue<int, vector<int>, less<int>> que;
  18. //next_permutation
  19. int ch[];
  20. int main()
  21. {
  22. int sum = ;
  23. string a;
  24. cin >> a;
  25. for (int i = ; i < a.size(); i++)
  26. {
  27. if (ch[a[i] - 'a'] == )
  28. {
  29. sum++;
  30. }
  31. ch[a[i] - 'a']++;
  32. }
  33. if (sum > )
  34. {
  35. cout << "No" << endl;
  36. return ;
  37. }
  38. if (sum == )
  39. {
  40. cout << "Yes" << endl;
  41. }
  42. else if (sum == )
  43. {
  44. for (int i = ; i <= ; i++)
  45. {
  46. if (ch[i] > )
  47. {
  48. cout << "Yes" << endl;
  49. return ;
  50. }
  51. }
  52. cout << "No" << endl;
  53. }
  54. else if (sum == )
  55. {
  56. for (int i = ; i <= ; i++)
  57. {
  58. if (ch[i] == )
  59. {
  60. cout << "No" << endl;
  61. return ;
  62. }
  63. }
  64. cout << "Yes" << endl;
  65. }
  66. else
  67. {
  68. cout << "No" << endl;
  69. }
  70. return ;
  71. }

C

给你Q(1~1e5)个询问 每个询问有L,R(1~1e18)

问你L~R之间有多少个"good number"  “good number"是a^p的数 a>0 p>1

因为总共有1e18个数 所以当p固定时 就有10^(18/p)个数 当p为2的时候很大 特殊处理 二分枚举checkL和R的sqrt得到答案

再来处理3~60部分(因为2^60>1e18)的答案 因为最大的10^(18/3)只有1e6所以可以全部枚举出来再nlogn排序去重 预处理复杂度为nlogn

  1. #include <bits/stdc++.h>
  2. #define PI acos(-1.0)
  3. #define mem(a,b) memset((a),b,sizeof(a))
  4. #define TS printf("!!!\n")
  5. #define pb push_back
  6. #define inf 1e9
  7. //std::ios::sync_with_stdio(false);
  8. using namespace std;
  9. //priority_queue<int,vector<int>,greater<int>> que; get min
  10. const double eps = 1.0e-10;
  11. typedef pair<int, int> pairint;
  12. typedef long long ll;
  13. typedef unsigned long long ull;
  14. //const int maxn = 3e5 + 10;
  15. const int maxn = ;
  16. const int turn[][] = {{, }, { -, }, {, }, {, -}};
  17. const int turn2[][] = {{, }, { -, }, {, }, {, -}, {, -}, { -, -}, {, }, { -, }};
  18. //priority_queue<int, vector<int>, less<int>> que;
  19. //next_permutation
  20. ll nowmaxn = 1e18;
  21. ll anser1;
  22. ll anser2;
  23. ll num[];
  24. int pop = ;
  25. //ll qpow(ll a, ll b)
  26. //{
  27. // ll ans = 1, base = a;
  28. // while (b != 0)
  29. // {
  30. // if (b & 1 != 0)
  31. // {
  32. //   ans *= base;
  33. // }
  34. // base *= base;
  35. // b >>= 1ll;
  36. //  
  37. // }
  38. // return ans;
  39. //}
  40. bool judge(ll x)
  41. {
  42. ll s = sqrt(x);
  43. for (ll i = s; i <= s + ; i++)
  44. {
  45. if (1LL * i * i == x)
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. void init()
  53. {
  54. ll now;
  55. ll limit;
  56. for (ll i = ; i <= ; i++)
  57. {
  58. limit = nowmaxn / i;
  59. now = 1LL * i * i;
  60. for (ll j = ;; j++)
  61. {
  62. now = 1LL * i * now;
  63. if (!judge(now))
  64. {
  65. num[pop++] = now;
  66. }
  67. if (now > limit)
  68. {
  69. break;
  70. }
  71. }
  72. }
  73. sort(num + , num + pop);
  74. pop = unique(num + , num + pop) - num;
  75. }
  76. ll gettwo(ll x)
  77. {
  78. ll ans;
  79. ll l = ;
  80. ll r = 2e9;
  81. while (l < r - )
  82. {
  83. ll mid = (l + r) >> ;
  84. if (mid * mid <= x)
  85. {
  86. l = mid;
  87. }
  88. else
  89. {
  90. r = mid;
  91. }
  92. }
  93. return l;
  94. }
  95. int main()
  96. {
  97. init();
  98. // for (int i = 1; i <= 10; i++)
  99. // {
  100. // cout << num[i] << " ";
  101. // }
  102. // cout << endl;
  103. ll L, R;
  104. int q;
  105. cin >> q;
  106. for (int i = ; i <= q; i++)
  107. {
  108. anser1 = anser2 = ;
  109. scanf("%lld %lld", &L, &R);
  110. if (L == )
  111. {
  112. anser1++;
  113. }
  114. anser1 = gettwo(R) - gettwo(L - );
  115. //cout << anser1 << endl;
  116. int L1 = lower_bound(num + , num + pop, L) - num;
  117. int R1 = lower_bound(num + , num + pop, R) - num;
  118. //cout << " " << L1 << " " << R1 << endl;
  119. if (L1 == R1)
  120. {
  121. if (num[L1] == R)
  122. {
  123. anser2++;
  124. }
  125. }
  126. else
  127. {
  128. anser2 = R1 - L1 + (num[R1] == R);
  129. }
  130. cout << anser1 + anser2 << endl;
  131. }
  132. }

Codeforces 955 LR询问 多次幂处理的更多相关文章

  1. codeforces magic five --快速幂模

    题目链接:http://codeforces.com/contest/327/problem/C 首先先算出一个周期里面的值,保存在ans里面,就是平常的快速幂模m做法. 然后要计算一个公式,比如有k ...

  2. CodeForces - 691E Xor-sequences 【矩阵快速幂】

    题目链接 http://codeforces.com/problemset/problem/691/E 题意 给出一个长度为n的序列,从其中选择k个数 组成长度为k的序列,因为(k 有可能 > ...

  3. Codeforces 963 A. Alternating Sum(快速幂,逆元)

    Codeforces 963 A. Alternating Sum 题目大意:给出一组长度为n+1且元素为1或者-1的数组S(0~n),数组每k个元素为一周期,保证n+1可以被k整除.给a和b,求对1 ...

  4. Codeforces 691E题解 DP+矩阵快速幂

    题面 传送门:http://codeforces.com/problemset/problem/691/E E. Xor-sequences time limit per test3 seconds ...

  5. 【codeforces 623E】dp+FFT+快速幂

    题目大意:用$[1,2^k-1]$之间的证书构造一个长度为$n$的序列$a_i$,令$b_i=a_1\ or\ a_2\ or\ ...\ or a_i$,问使得b序列严格递增的方案数,答案对$10^ ...

  6. Codeforces 691E Xor-sequences(矩阵快速幂)

    You are given n integers a1,  a2,  ...,  an. A sequence of integers x1,  x2,  ...,  xk is called a & ...

  7. codeforces 696C C. PLEASE(概率+快速幂)

    题目链接: C. PLEASE time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. Codeforces 954 dijsktra 离散化矩阵快速幂DP 前缀和二分check

    A B C D 给你一个联通图 给定S,T 要求你加一条边使得ST的最短距离不会减少 问你有多少种方法 因为N<=1000 所以N^2枚举边数 迪杰斯特拉两次 求出Sdis 和 Tdis 如果d ...

  9. [Luogu3242][HNOI2015]接水果

    Luogu 我今天做两道整体二分结果全都是BZOJ权限题??? sol 我们抓住"盘子的路径是水果的路径的子路径"这个条件. 考虑每一个盘子路径\((u,v)\),讨论它可以作为哪 ...

随机推荐

  1. OOM和SOF代码

    OutOfMemoryError大数组,例如图片加载. public class MockOutOfMemoryError { public static void main(String[] arg ...

  2. 错误 NETSDK1007 找不到“E:\Project\MyProject\MyProject.Common\MyProject.Utility.csproj”的项目信息。这可以指示缺少一个项目引用。 MyProject.Data C:\Program Files\dotnet\sdk\2.2.107\Sdks\Microsoft.NET.Sdk\targets\Microsof

    因为对MyProject.Data引用的项目MyProject.Common进行了重命名为MyProject.Utility,导致这个错误 解决办法: 1.找到MyProject.Data中的E:\P ...

  3. HashMap,ConcurrentHashMap相关知识整理

    1.HashMap的存储步骤: 1.传入key和value,判断key是否为null,如果为null,则调用putForNullKey,以null作为key存储到哈希表中: 2. 然后计算key的ha ...

  4. 安装mysql出现Couldn't find MySQL server (/usr/bin/mysqld_safe)

    安装mysql出现Couldn't find MySQL server (/usr/bin/mysqld_safe)Starting MySQL ERROR! Couldn't find MySQL ...

  5. 阶段3 1.Mybatis_05.使用Mybatis完成CRUD_1 回顾Mybatis的环境搭建-实现查询所有功能

    先回顾Mybits的环境搭建,. 直接next 直接点击finish 创建好的项目. 所有东西都自己写不现实,约束文件的头部还是拷贝过来 导入依赖坐标,Mybits mysql的驱动 log4j 单元 ...

  6. Java ——异常处理

    本节重点思维导图 详细戳——> 异常处理

  7. 8.FTP后门命令执行----Samba命令执行----VMware安装kali----多终端显示

    FTP后门命令执行 再次声明,最近听闻不得教受工具使用等言论. 我敢打包票,网络空间安全一级学科的老师和学生是不会说这句话的.未知攻,焉知防. 有工具来检测自己和玩弄它,是幸运的. 犯罪者不会给你提供 ...

  8. git自动上传脚本及基本代码

    git_auto.bat git add . git add -A git add -u git commit -m "text" git pull --rebase origin ...

  9. new 和 malloc 的区别 及使用

    Malloc: 定义上:malloc  memory allocation 动态内存分配 是c中的一个函数 使用方法: extern void *malloc(unsigned int num_byt ...

  10. 【监控笔记】【1.4】Pssdiag和Sqldiag管理器

    --没有实操过,有点复杂,先写上以后有用到再深入研究 统计与诊断数据是任何 SQL故障修复工作的关键所在. 如果没有掌握这些数据,就无法确定数据性能问题的根源.数据表的瓶颈可能并不是由索引问题造成的: ...