Codeforces 984 扫雷check 欧几里得b进制分数有限小数判定 f函数最大连续子段
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函数最大连续子段的更多相关文章
- Vulnerable Kerbals CodeForces - 772C【拓展欧几里得建图+DAG上求最长路】
根据拓展欧几里得对于同余方程 $ax+by=c$ ,有解的条件是 $(a,b)|c$. 那么对于构造的序列的数,前一个数 $a$ 和后一个数 $b$ ,应该满足 $a*x=b(mod m)$ 即 $ ...
- Codeforces Round #538 (Div. 2) C 数论 + 求b进制后缀零
https://codeforces.com/contest/1114/problem/C 题意 给你一个数n(<=1e8),要你求出n!在b进制下的后缀零个数(b<=1e12) 题解 a ...
- 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 ...
- 【扩展欧几里得】BAPC2014 I Interesting Integers (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions
题目链接: http://codeforces.com/problemset/problem/710/D 题目大意: 两个等差数列a1x+b1和a2x+b2,求L到R区间内重叠的点有几个. 0 < ...
- Codeforces Gym100812 L. Knights without Fear and Reproach-扩展欧几里得(exgcd)
补一篇以前的扩展欧几里得的题,发现以前写错了竟然也过了,可能数据水??? 这个题还是很有意思的,和队友吵了两天,一边吵一边发现问题??? L. Knights without Fear and Rep ...
- [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 ...
- Codeforces 7C 扩展欧几里得
扩展欧几里得是计算 ax + by = gcd(a,b) 的 x,y的整数解. 现在是ax + by + c = 0; 只要 -c 是 gcd(a,b) 的整数倍时有整数解,整数解是 x = x*(- ...
- 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 ...
随机推荐
- 统计学_Wilcoxon signed-rank test(python脚本)
python机器学习-乳腺癌细胞挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003&u ...
- leecode 309. 最佳买卖股票时机含冷冻期
/***** //sell[i]表示截至第i天,最后一个操作是卖时的最大收益: //buy[i]表示截至第i天,最后一个操作是买时的最大收益: //cool[i]表示截至第i天,最后一个操作是冷冻期时 ...
- leetcode 148排序链表
优先队列容器,使用小顶堆排序:timeO(nlogn) spaceO(n) /** * Definition for singly-linked list. * struct ListNode { * ...
- Python之输入输出
python中变量的输出 # 打印提示 print('hello world') print('你好!') # 输出变量 url = 'loaderman' print('我是:',url) prin ...
- [mysql]root用户登录mysql,输入密码后报错:Access denied for user 'root'@'localhost'
问题如下: wangju-G4:~$ mysql -u root -p Enter password: ERROR (): Access denied for user 'root'@'localho ...
- 第三章 SpringCloud之Eureka-Client服务提供者
1.Eureka-Client简介 #################接下来开始程序啦########################## 1.pom.xml <?xml version=&qu ...
- deepin的15.11中安装nvidia最新435版本驱动
换了一个电脑,跟随潮流,CPU是不带集显的,操作系统从原来的硬盘一通搬过来的 其中Deepin Linux更新到15.11. 显卡是2060的,在Deepin中目前只集成了390的nvidia驱动,无 ...
- jquery实现分页效果
通过jq实现分页的原理如下:将所有条数加载到页面中,根据每页放特定条数(例如 5 条)获取jquery对象索引,使部分条数显示,其他条数隐藏. 前提:引入jquery.js 代码 <!DOCTY ...
- JavaScript中:地址引用的特性,导致静态初始值被修改
问题分类 JavaScript,值引用,地址引用 问题描述 开发过程中,服务端将静态配置数据从mysql数据库中读取到内存中,方便调用. 在实现流派功能时,需从数据库中读取流派种类数据到内存中,由于其 ...
- springMvc中获取通过注解获取properties配置文件(转)
springMvc的项目中,通过注解@Value获取properties配置文件中的配置,使用该注解必须引入的包: spring-beans-4.1.4.RELEASE.jar 下面是需要在sprin ...