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. python获取豆瓣日记

    最近迷上了看了四个春天,迷上了饭叔的豆瓣日记,想全部抓取下来,简单了写了下面的脚本 import urllib.request import os from bs4 import BeautifulS ...

  2. SQL2008附加数据库报错

    sql server 2008如何导入mdf,ldf文件 网上找了很多解决sql server导入其他电脑拷过来的mdf文件,多数是不全,遇到的解决方法不一样等问题,下边是找到的解决问题的最全面方法! ...

  3. ControlTemplate in WPF —— Shared in all file

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x ...

  4. 阶段3 2.Spring_08.面向切面编程 AOP_8 spring中的环绕通知

    环绕通知.method属性需要新加一个方法 在logger内中新加aroundPringLog方法 异常代码先注释掉 对比现在的环绕通知和之前写代理类做的环绕通知.右侧的方法内有明确的业务层方法(切入 ...

  5. HttpRunnerManager(一)--安装

    1.相关地址 (1)中文文档介绍:https://cn.httprunner.org/ (2)相关安装包下载地址:链接:https://pan.baidu.com/s/13SP1mFsNKrLK0sn ...

  6. vue v-for直接循环数字

    <svg class="icon" aria-hidden="true" v-for="index of 5" :key=" ...

  7. pcap中不同包功能

    1.不同包协议的功能 EAPoL:基于局域网的扩展认证协议 ICMPv6:(一般是四个连在一起)互联网控制协议第六套 DHCP Discover:请求分配IP DHCP Offer:你的IP是***, ...

  8. poatman接口测试--初试

    接到测试任务,对两个商品接口,进行接口测试 测试工具:postman 域名:rap2查找的或询问开发, 接口的参数规则:参考rap2的备注 开发没有添加详细说明的,让开发补充说明规则,及定义的返回状态 ...

  9. 手写BP(反向传播)算法

    BP算法为深度学习中参数更新的重要角色,一般基于loss对参数的偏导进行更新. 一些根据均方误差,每层默认激活函数sigmoid(不同激活函数,则更新公式不一样) 假设网络如图所示: 则更新公式为: ...

  10. 2019JAVA第四次实验报告

    JAVA实验报告 班级 计科二班 学号 20188442 姓名 吴怡君 完成时间 2019/9/29 评分等级 实验四 类的继承 1.实验目的 掌握类的继承方法: 变量的继承和覆盖,方法的继承.重载和 ...