A

/* Huyyt */
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mkp(a,b) make_pair(a,b)
#define pb push_back
using namespace std;
typedef long long ll;
const long long mod = 1e9 + ;
const int N = 2e5 + ;
int num[];
int main()
{
int n;
cin >> n;
for(int i=;i<=n;i++)
{
cin >> num[i];
}
sort(num+,num++n);
int now=;
if(n%)
{
cout<<num[n/+]<<endl;
}
else
{
cout<<num[n/]<<endl;
}
}

B

/* Huyyt */
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mkp(a,b) make_pair(a,b)
#define pb push_back
const int dir[][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }};
using namespace std;
typedef long long ll;
const long long mod = 1e9 + ;
const int N = 2e5 + ;
char f[][];
int n, m;
bool ok(int x, int y)
{
if (x > n || x < )
{
return false;
}
if (y > m || y < )
{
return false;
}
return true;
}
int main()
{
cin >> n >> m;
for (int i = ; i <= n; i++)
{
scanf("%s", f[i] + );
}
for (int i = ; i <= n; i++)
{
for (int j = ; j <= m; j++)
{
if (f[i][j] == '*')
{
continue;
}
if (f[i][j] == '.')
{
for (int w = ; w < ; w++)
{
int dx = i + dir[w][];
int dy = j + dir[w][];
if (ok(dx, dy))
{
if (f[dx][dy] == '*')
{
cout << "NO" << endl;
return ;
}
}
}
}
else
{
int now = ;
int cur = f[i][j] - '';
for (int w = ; w < ; w++)
{
int dx = i + dir[w][];
int dy = j + dir[w][];
if (ok(dx, dy))
{
if (f[dx][dy] == '*')
{
now++;
}
}
}
if (now != cur)
{
cout << "NO" << endl;
return ;
}
} }
}
cout << "YES" << endl;
return ;
}

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的质因子

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll LLmaxn = 2e18;
const int N = ;
int n;
inline ll readint()
{
char c = getchar();
ll ans = ;
while (c < '' || c > '')
{
c = getchar();
}
while (c >= '' && c <= '')
{
ans = ans * 10LL + c - '', c = getchar();
}
return ans;
}
ll gcd(ll a, ll b)
{
ll t;
while (b)
{
t = b;
b = a % b;
a = t;
}
return a;
}
int main()
{
n=readint();
ll p, q, b;
for (int i = ; i <= n; i++)
{
p=readint(),q=readint(),b=readint();
ll now = gcd(p, q);
p /= now, q /= now;
if (q == )
{
cout << "Finite" << endl;
continue;
}
p %= q;
if (p == )
{
cout << "Finite" << endl;
continue;
}
now = gcd(q, b);
while (now != )
{
while (q % now == )
{
q /= now;
}
now=gcd(q,b);
}
if (q == )
{
cout << "Finite" << endl;
}
else
{
cout << "Infinite" << endl;
} }
}

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])

/*Huyyt*/
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll LLmaxn = 2e18;
const int N = ;
inline int readint()
{
char c = getchar();
int ans = ;
while (c < '' || c > '')
{
c = getchar();
}
while (c >= '' && c <= '')
{
ans = ans * + c - '', c = getchar();
}
return ans;
}
int number[];
int dp[][];
int main()
{
int now = ;
int n;
n = readint();
for (int i = ; i <= n; i++)
{
number[i] = readint();
}
for (int i = ; i <= n; i++)
{
dp[i][i] = number[i];
}
for (int len = ; len <= n - ; len++)
{
for (int i = ; i <= n - len; i++)
{
dp[i][i + len] = dp[i][i + len - ] ^ dp[i + ][i + len];
}
}
for (int len = ; len <= n - ; len++)
{
for (int i = ; i <= n - len; i++)
{
dp[i][i + len] = max(max(dp[i][i + len - ], dp[i + ][i + len]), dp[i][i + len]);
}
}
int l, r;
int q;
q = readint();
while (q--)
{
l = readint(), r = readint();
cout << dp[l][r] << endl;
}
}

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. ggsci: error while loading shared libraries: libnnz11.so: cannot open shared object file

    完整的错误信息如下: ggsci: error while loading shared libraries: libnnz11.so: cannot open shared object file: ...

  2. nginx代理,负载均衡

    #代理,如:通过代理实现访问百度(单个机器)创建vim proxy.conf内容如下server { listen 80; server_name www.baidu.com; location / ...

  3. 阶段3 2.Spring_01.Spring框架简介_01.spring课程四天安排

    spring共四天 第一天:spring框架的概述以及spring中基于XML的IOC配置 第二天:spring中基于注解的IOC和ioc的案例 第三天:spring中的aop和基于XML以及注解的A ...

  4. git pull 覆盖本地代码

    在使用Git的过程中,有些时候我们只想要git服务器中的最新版本的项目,对于本地的项目中修改不做任何理会,就需要用到Git pull的强制覆盖,具体代码如下: $ git fetch --all $ ...

  5. vim 编辑提示swap file already exists 解决方法

    linux服务器上编辑 .ini 文件时卡死,关闭连接工具后重新进入操作该 .ini 文件时,会提示: E325: ATTENTION Found a swap file by the name &q ...

  6. Python新手最容易犯的十大错误

    1. 忘记写冒号 在 if.elif.else.for.while.class.def 语句后面忘记添加“:” if spam == 42 print('Hello!') 2. 误用 “=” 做等值比 ...

  7. Python中调用c语言(简单版)

    Python中有时需要调用c程序中的函数.使用ctype库可以很方便地调用c语言.现说明方法,以及注意事项. c程序编译为.so文件: 我们需要的c语言文件为test.c,要从其中调用func(x,y ...

  8. 20191209 【归档】Linux就该这么学

    学习背景 因为打算学习Redis和Docker,但是发现对Linux的操作已经完全忘记了,所以选择再学一次,但是不会深入的学习,选择了<Linux就该这么学>这本书,学完了感觉还挺好,但是 ...

  9. angular [NgClass] [NgStyle],NgIf,[ngSwitch][ngSwitchCase]

    [NgClass]  CSS 类会根据表达式求值结果进行更新,更新逻辑取决于结果的类型: string - 会把列在字符串中的 CSS 类(空格分隔)添加进来, Array - 会把数组中的各个元素作 ...

  10. Neo4j下载与使用

    Neo4j 官网 : https://neo4j.com/ Neo4j 国内: http://neo4j.com.cn/topic/5b003eae9662eee704f31cee http://we ...