A

  1. /* Huyyt */
  2. #include <bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define mkp(a,b) make_pair(a,b)
  5. #define pb push_back
  6. using namespace std;
  7. typedef long long ll;
  8. const long long mod = 1e9 + ;
  9. const int N = 2e5 + ;
  10. int num[];
  11. int main()
  12. {
  13. int n;
  14. cin >> n;
  15. for(int i=;i<=n;i++)
  16. {
  17. cin >> num[i];
  18. }
  19. sort(num+,num++n);
  20. int now=;
  21. if(n%)
  22. {
  23. cout<<num[n/+]<<endl;
  24. }
  25. else
  26. {
  27. cout<<num[n/]<<endl;
  28. }
  29. }

B

  1. /* Huyyt */
  2. #include <bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define mkp(a,b) make_pair(a,b)
  5. #define pb push_back
  6. const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
  7. using namespace std;
  8. typedef long long ll;
  9. const long long mod = 1e9 + ;
  10. const int N = 2e5 + ;
  11. char f[][];
  12. int n, m;
  13. bool ok(int x, int y)
  14. {
  15. if (x > n || x < )
  16. {
  17. return false;
  18. }
  19. if (y > m || y < )
  20. {
  21. return false;
  22. }
  23. return true;
  24. }
  25. int main()
  26. {
  27. cin >> n >> m;
  28. for (int i = ; i <= n; i++)
  29. {
  30. scanf("%s", f[i] + );
  31. }
  32. for (int i = ; i <= n; i++)
  33. {
  34. for (int j = ; j <= m; j++)
  35. {
  36. if (f[i][j] == '*')
  37. {
  38. continue;
  39. }
  40. if (f[i][j] == '.')
  41. {
  42. for (int w = ; w < ; w++)
  43. {
  44. int dx = i + dir[w][];
  45. int dy = j + dir[w][];
  46. if (ok(dx, dy))
  47. {
  48. if (f[dx][dy] == '*')
  49. {
  50. cout << "NO" << endl;
  51. return ;
  52. }
  53. }
  54. }
  55. }
  56. else
  57. {
  58. int now = ;
  59. int cur = f[i][j] - '';
  60. for (int w = ; w < ; w++)
  61. {
  62. int dx = i + dir[w][];
  63. int dy = j + dir[w][];
  64. if (ok(dx, dy))
  65. {
  66. if (f[dx][dy] == '*')
  67. {
  68. now++;
  69. }
  70. }
  71. }
  72. if (now != cur)
  73. {
  74. cout << "NO" << endl;
  75. return ;
  76. }
  77. }
  78.  
  79. }
  80. }
  81. cout << "YES" << endl;
  82. return ;
  83. }

C

好题。。应该是我做过最难的2C了

给你 p q b 三个1e18的数 问你在b进制下p/q能不能被有限地表现出来

首先把p与q约分 考虑1/q能不能在b进制在被表现出来

因为b进制下每退一位所表示的数就小b倍

所以我们可以把被除数乘上b再除q就是这一位小数的值 即\(\frac{3*4}{5}=2\)

同时被除数变为\(\frac{3}{5}\)\(\%\) \(\frac{1}{4}\)=\(\frac{(3*4)\%5}{5}\)=\(\frac{2}{5}\)

这样进行下去看能不能在某一步被除数分子乘上b是q的倍数

即存在n使得 \(b^{n}\ mod\ q=0\) 但是我们不可能枚举n来检验是否存在

由唯一分解定理可知 \(b^{n}\ mod\ q=0\) 等价于b的因子中存在所有q的质因子

  1. /*Huyyt*/
  2. #include<bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define pb push_back
  5. using namespace std;
  6. typedef long long ll;
  7. typedef unsigned long long ull;
  8. const ll LLmaxn = 2e18;
  9. const int N = ;
  10. int n;
  11. inline ll readint()
  12. {
  13. char c = getchar();
  14. ll ans = ;
  15. while (c < '' || c > '')
  16. {
  17. c = getchar();
  18. }
  19. while (c >= '' && c <= '')
  20. {
  21. ans = ans * 10LL + c - '', c = getchar();
  22. }
  23. return ans;
  24. }
  25. ll gcd(ll a, ll b)
  26. {
  27. ll t;
  28. while (b)
  29. {
  30. t = b;
  31. b = a % b;
  32. a = t;
  33. }
  34. return a;
  35. }
  36. int main()
  37. {
  38. n=readint();
  39. ll p, q, b;
  40. for (int i = ; i <= n; i++)
  41. {
  42. p=readint(),q=readint(),b=readint();
  43. ll now = gcd(p, q);
  44. p /= now, q /= now;
  45. if (q == )
  46. {
  47. cout << "Finite" << endl;
  48. continue;
  49. }
  50. p %= q;
  51. if (p == )
  52. {
  53. cout << "Finite" << endl;
  54. continue;
  55. }
  56. now = gcd(q, b);
  57. while (now != )
  58. {
  59. while (q % now == )
  60. {
  61. q /= now;
  62. }
  63. now=gcd(q,b);
  64. }
  65. if (q == )
  66. {
  67. cout << "Finite" << endl;
  68. }
  69. else
  70. {
  71. cout << "Infinite" << endl;
  72. }
  73.  
  74. }
  75. }

D

给你一个f函数(类似于石子合并花费 只是把+变成XOR操作)

直接n2用类似石子合并的思想先把小的区间处理出来dp[i][i + len] = dp[i][i + len - 1] ^ dp[i + 1][i + len]

再汇总dp[i][i + len] = max(max(dp[i][i + len - 1], dp[i + 1][i + len]), dp[i][i + len])

  1. /*Huyyt*/
  2. #include<bits/stdc++.h>
  3. #define mem(a,b) memset(a,b,sizeof(a))
  4. #define pb push_back
  5. using namespace std;
  6. typedef long long ll;
  7. typedef unsigned long long ull;
  8. const ll LLmaxn = 2e18;
  9. const int N = ;
  10. inline int readint()
  11. {
  12. char c = getchar();
  13. int ans = ;
  14. while (c < '' || c > '')
  15. {
  16. c = getchar();
  17. }
  18. while (c >= '' && c <= '')
  19. {
  20. ans = ans * + c - '', c = getchar();
  21. }
  22. return ans;
  23. }
  24. int number[];
  25. int dp[][];
  26. int main()
  27. {
  28. int now = ;
  29. int n;
  30. n = readint();
  31. for (int i = ; i <= n; i++)
  32. {
  33. number[i] = readint();
  34. }
  35. for (int i = ; i <= n; i++)
  36. {
  37. dp[i][i] = number[i];
  38. }
  39. for (int len = ; len <= n - ; len++)
  40. {
  41. for (int i = ; i <= n - len; i++)
  42. {
  43. dp[i][i + len] = dp[i][i + len - ] ^ dp[i + ][i + len];
  44. }
  45. }
  46. for (int len = ; len <= n - ; len++)
  47. {
  48. for (int i = ; i <= n - len; i++)
  49. {
  50. dp[i][i + len] = max(max(dp[i][i + len - ], dp[i + ][i + len]), dp[i][i + len]);
  51. }
  52. }
  53. int l, r;
  54. int q;
  55. q = readint();
  56. while (q--)
  57. {
  58. l = readint(), r = readint();
  59. cout << dp[l][r] << endl;
  60. }
  61. }

Codeforces 984 扫雷check 欧几里得b进制分数有限小数判定 f函数最大连续子段的更多相关文章

  1. Vulnerable Kerbals CodeForces - 772C【拓展欧几里得建图+DAG上求最长路】

    根据拓展欧几里得对于同余方程 $ax+by=c$ ,有解的条件是 $(a,b)|c$. 那么对于构造的序列的数,前一个数 $a$  和后一个数 $b$ ,应该满足 $a*x=b(mod m)$ 即 $ ...

  2. Codeforces Round #538 (Div. 2) C 数论 + 求b进制后缀零

    https://codeforces.com/contest/1114/problem/C 题意 给你一个数n(<=1e8),要你求出n!在b进制下的后缀零个数(b<=1e12) 题解 a ...

  3. Codeforces Round #444 (Div. 2)A. Div. 64【进制思维】

    A. Div. 64 time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  4. 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)

    题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...

  5. 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions

    题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...

  6. Codeforces Gym100812 L. Knights without Fear and Reproach-扩展欧几里得(exgcd)

    补一篇以前的扩展欧几里得的题,发现以前写错了竟然也过了,可能数据水??? 这个题还是很有意思的,和队友吵了两天,一边吵一边发现问题??? L. Knights without Fear and Rep ...

  7. [codeforces 200 E Tractor College]枚举,扩展欧几里得,三分

    题目出自 Codeforces Round #126 (Div. 2) 的E. 题意大致如下:给定a,b,c,s,求三个非负整数x,y,z,满足0<=x<=y<=z,ax+by+cz ...

  8. Codeforces 7C 扩展欧几里得

    扩展欧几里得是计算 ax + by = gcd(a,b) 的 x,y的整数解. 现在是ax + by + c = 0; 只要 -c 是 gcd(a,b) 的整数倍时有整数解,整数解是 x = x*(- ...

  9. Codeforces Round #451 (Div. 2) B. Proper Nutrition【枚举/扩展欧几里得/给你n问有没有两个非负整数x,y满足x·a + y·b = n】

    B. Proper Nutrition time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. Iris Classification on Keras

    Iris Classification on Keras Installation Python3 版本为 3.6.4 : : Anaconda conda install tensorflow==1 ...

  2. 学习笔记 - Git

    学习参考网址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 Git是目前世界上 ...

  3. Spring Cloud负载均衡:使用zuul作服务器端负载均衡

    1.目的: 本文简述Spring Cloud负载均衡之服务器负载均衡模式,使用组件为zuul. zuul作为Spring Cloud中的网关组件,负责路由转发.身份验证.请求过滤等等功能,那么我们可以 ...

  4. 阶段3 2.Spring_06.Spring的新注解_7 spring整合junit问题分析

    测试类重复代码的问题 这是之前的方式 运行findAll的方法,没有问题 测试人员不需要关心上面的方法,.应该关心的各个方法是否能够正常的运行 对于一个测试工程师,只要写完变量就可以测试了. 可以使用 ...

  5. Maven 安装 / 常用配置 / 阿里maven中央仓库

    Maven 官方下载地址: http://maven.apache.org/download.cgi 可以选择清华的镜像: 解压在settings.xml里面配置阿里中央仓库: <mirror& ...

  6. JAVA 内存的那些事

    (转载)固然Java屏蔽了一下内存细节,但是有时候,了解一下这些常识还是有好处的,特别是一些口试,总是盯着这些玩意不放手. JVM启动以后,会分配两类内存区域,一类用于开发职员使用,比如保存一些变量, ...

  7. linu基础命令1

    /根目录,第一级目录 1.ls列出当前目录下的文件和目录-a: 列出所有的文件,包括所有以.开头的隐藏文件-d: 列出目录本身,并不包含目录中的文件(-ld)-h: 和-l一起使用,文件大小人类易读 ...

  8. 通过NGINX location实现一个域名访问多个项目

    location ~ \.php$ { root /home/webroot;    //此目录下有多个项目 project1 ,project2... fastcgi_pass $php_upstr ...

  9. cocos2dx基础篇(7) 触碰事件

    cocos2dx游戏引擎的重点是在于移动设备的跨平台开发,而移动设备上的游戏大部分都是通过屏幕触碰来进行的.比如主菜单的按钮触碰,打飞机中飞机的触碰移动,都需要用到触碰操作.想一想之前讲的菜单按钮CC ...

  10. LeetCode.922-按奇偶排序数组 II(Sort Array By Parity II)

    这是悦乐书的第354次更新,第379篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第216题(顺位题号是922).给定非负整数的数组A,A中的一半整数是奇数,而剩下的一半 ...