Educational Codeforces Round 118 (Rated for Div. 2)

A - Long Comparison
B - Absent Remainder
C - Poisoned Dagger
D - MEX Sequences
E - Crazy Robot

拿字符串比较

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#define mid (l+r>>1)
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 2e6+10, mod = 1e9 + 7;
void mull(int &a, LL b){a = a*b%mod;return ;}
void add(int &a, LL b){a = (a+b)%mod;return ;}int main() 
{	int t;scanf("%d", &t);while(t --){string a, b;int c, d, f = 1;cin>>a>>c>>b>>d;while(a.size()<b.size()&&c)a+='0', c--;while(a.size()>b.size()&&d)b+='0', d--;int la = a.size()+c, lb = b.size()+d;if(la < lb) f = -1;else if(la == lb){if(a == b)f = 0;else if(a > b)f = 1;else f = -1;}if(f == 1)puts(">");else if(f == -1)puts("<");else puts("=");} return 0;
}

ymodx=t,ify>x,t<xy\,mod\,x = t, \,if y > x,t < xymodx=t,ify>x,t<x,那么x取最小值

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#define mid (l+r>>1)
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 2e6+10, mod = 1e9 + 7;
void mull(int &a, LL b){a = a*b%mod;return ;}
void add(int &a, LL b){a = (a+b)%mod;return ;}int a[N];
int main() 
{	int t;scanf("%d", &t);while(t --){int n;scanf("%d", &n);for(int i = 0;i < n;i ++)scanf("%d", a+i);sort(a, a+n);int len = n/2, x = 1;while(len --)printf("%d %d\n", a[x++], a[0]);	} return 0;
}

答案具有单调性,那么可以二分nlognnlog\,nnlogn

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#define mid (l+r>>1)
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 2e6+10, mod = 1e9 + 7;
void mull(int &a, LL b){a = a*b%mod;return ;}
void add(int &a, LL b){a = (a+b)%mod;return ;}int a[N], n;
LL h;bool ch(LL x)
{LL sum = 0, tail = 0;for(int i = 1;i <= n;tail = max(tail, a[i]+x), i ++)tail < a[i] ? sum += x : sum += a[i]+x-tail;return sum >= h;
}int main() 
{	int t;scanf("%d", &t);while(t --){scanf("%d%lld", &n, &h);for(int i = 1;i <= n;i ++)scanf("%d", a+i);LL l = 1, r = 1e18;while(l < r){if(ch(mid))r = mid;else l = mid+1;}cout<<l<<endl;} return 0;
}

dp,dp[i][0/1]表示mex=i,max=i−1ori+1dp,dp[i][0/1] 表示mex = i,max = i-1\,or\,i+1dp,dp[i][0/1]mex=imax=i1ori+1 然后开始疯狂的推式子了,ai会和dp[ai−1],dp[ai],dp[ai+1]a_i会和dp[a_i-1],dp[a_i],dp[a_i+1]aidp[ai1],dp[ai],dp[ai+1] 有影响,我把所有的数字都右移了1,因为不移1的话初始状态是dp[−1][1]=1dp[-1][1]=1dp[1][1]=1

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#define mid (l+r>>1)
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 2e6+10, mod = 998244353;
void mull(int &a, LL b){a = a*b%mod;return ;}
void add(int &a, LL b){a = (a+b)%mod;return ;}int in[N], dp[N][2];int main() 
{	int t;scanf("%d", &t);while(t --){int n;scanf("%d", &n);int ans = 0;dp[1][0] = 1;for(int i = 1;i <= n;i ++){int x;scanf("%d", &x); ++x;add(ans, (LL)dp[x+1][0]+dp[x+1][1]+dp[x][0]+dp[x-1][1]+dp[x-1][0]);add(dp[x-1][1], dp[x-1][1] + dp[x-1][0]);mull(dp[x+1][1], 2);add(dp[x+1][0], dp[x+1][0] + dp[x][0]);}for(int i = 1;i <= n+1;i ++)dp[i][0] = dp[i][1] = 0; cout<<ans<<endl;} return 0;
}

这题想简单了,哎。要边遍历边修改

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#define mid (l+r>>1)
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 1e6+10, mod = 998244353;
void mull(int &a, LL b){a = a*b%mod;return ;}
void add(int &a, LL b){a = (a+b)%mod;return ;}int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};int main() 
{	int t;scanf("%d", &t);while(t --){int n, m, x, y;scanf("%d%d", &n, &m);char a[n+1][m+1] ;   for(int i = 1;i <= n;i ++){scanf("%s", a[i]+1);for(int j = 1;j <= m;j ++)if(a[i][j] == 'L')x = i, y = j;}queue<PII>q;while(!q.empty())q.pop();	for(int i = 0;i < 4;i ++)q.push({x+dx[i], y+dy[i]});a[x][y] = '+';while(!q.empty()){int x = q.front().first, y = q.front().second, l = 0, r = 0;q.pop();if(!x || x>n || !y || y>m || a[x][y] != '.') continue;for(int i = 0;i < 4;i ++){int ll = x+dx[i], rr = y+dy[i];if(!ll || ll>n ||!rr || rr>m)continue;l += a[x+dx[i]][y+dy[i]] == '.', r += a[x+dx[i]][y+dy[i]] == '+';}if(!r || l > 1 )continue;a[x][y] = '+';for(int i = 0;i < 4;i ++)q.push({x+dx[i], y+dy[i]});}		a[x][y] = 'L';for(int i = 1;i <= n;i ++)printf("%s\n",a[i]+1);} return 0;
}
//#....
//..##L
//...#.
//.....

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/316149.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

eShopOnContainers 是一个基于微服务的.NET Core示例框架

找到一个好的示例框架很难&#xff0c;但不是不可能。大多数是小型Todo风格的应用程序&#xff0c;通常基于SimpleCRUD。值得庆幸的是&#xff0c;Microsoft已经为eShopOnContainers创建了一个基于微服务的.NET Core示例应用程序。eShopOnContainers是 .NET Core示例应用框架&a…

P1447 [NOI2010] 能量采集

P1447 [NOI2010] 能量采集 题意&#xff1a; 如果一棵植物与能量汇集机器(坐标为0&#xff0c;0)连接而成的线段上有 k 棵植物&#xff0c;则能量的损失为 2k 1 给你一个n*m的植物园&#xff0c;问能量损失是多少 1<n,m<1e5 题解&#xff1a; 本题所求式子为&#x…

P1232 [NOI2013] 树的计数

…调半天别的东西写错了&#xff0c;心力交瘁。 思路还是不会。。 具体就是二分&#xff0c;没想到&#xff0c;然后再贪心。 一直没整明白一个数它要往别的树走的条件是什么&#xff0c;日后研究。 #include <iostream> #include <cstdio> #include <cstring&…

「拥抱开源, 又见 .NET」系列第三次线下活动简报

「拥抱开源, 又见 .NET」随着 .NET Core的发布和开源&#xff0c;.NET又重新回到人们的视野。自2016年 .NET Core 1.0 发布以来&#xff0c;其强大的生命力让越来越多技术爱好者对她的未来满怀憧憬&#xff0c;越来越多的平台、框架热衷于为.NET Core不断更新的版本提供最有力的…

P3302 SDOI2013森林

P3302 [SDOI2013]森林 题意&#xff1a; 一片森林&#xff0c;有n个节点&#xff0c;m个边&#xff0c;现在有t个操作&#xff0c; Q x y k&#xff1a;Q x y k 查询点 x 到点 y 路径上所有的权值中&#xff0c;第 k 小的权值是多少 L x y 在点 x 和点 y 之间连接一条边。保证…

Codeforces Round #759 (Div. 2, based on Technocup 2022 Elimination Round 3)

感觉E思路明确只用了stl树状数组&#xff0c;F线段树复合修改&#xff0c;为什么都是2400。 A. Life of a Flower B. Array Eversion C. Minimize Distance E. Frequency Queries F. Non-equal Neighbours F : 首先 dp[i][j]sum[dp[i−1]]−dp[i−1][j]dp[i][j] sum[dp[i-1]] …

请给你的短信验证码接口加上SSL双向验证

序言去年年底闲来几天&#xff0c;有位同事专门在网上找一些注册型的app和网站&#xff0c;研究其短信接口是否安全&#xff0c;半天下来找到30来家&#xff0c;一些短信接口由于分析难度原因&#xff0c;没有继续深入&#xff0c;但差不多挖掘到20来个&#xff0c;可以肆意被调…

P2498 [SDOI2012]拯救小云公主

P2498 [SDOI2012]拯救小云公主 题意&#xff1a; 一个row * line的矩形&#xff0c;英雄在左下角(1,1),公主在右上角(row,line),有n个位置是boss。英雄现在要去公主那里&#xff0c;但是要避开boos&#xff0c;英雄决定找一条路径使到距离boss的最短距离最远。雄走的方向是任…

AtCoder Beginner Contest 230

A - AtCoder Quiz 3 B - Triple Metre C - X drawing 暂无 D - Destroyer Takahashi 暂无 贪心好难啊 E - Fraction Floor Sum F - Predilection G - GCD Permutation H - Bullion无 AAA int t;scanf("%d", &t);t t>42;printf("AGC%03d", t);BBB …

在Asp.Net Core中集成Kafka

在我们的业务中&#xff0c;我们通常需要在自己的业务子系统之间相互发送消息&#xff0c;一端去发送消息另一端去消费当前消息&#xff0c;这就涉及到使用消息队列MQ的一些内容&#xff0c;消息队列成熟的框架有多种&#xff0c;这里你可以读这篇文章来了解这些MQ的不同&#…

生成函数(母函数)

参考文章&#xff1a; 生成函数(母函数)——目前最全的讲解 《小学生都能看懂的生成函数从入门到升天教程》《生成函数全家桶》 Acwing 进阶课程–生成函数 引入 任意给定一个无限长的序列a0,a1....an....a_{0},a_{1}....a_{n}....a0​,a1​....an​.... 定义函数g(x)a0x0a1x…

AtCoder Beginner Contest 234

A - Weird Function B - Longest Segment C - Happy New Year! D - Prefix K-th Max E - Arithmetic Number F - Reordering G - Divide a Sequence 写个函数 int f(int x){return x*x2*x3;} int main() { int t;scanf("%d", &t);cout<<f(f(f(t)t)f(f(t…

分享一个.NET平台开源免费跨平台的大数据分析框架.NET for Apache Spark

今天早上六点半左右微信群里就看到张队发的关于.NET Spark大数据的链接https://devblogs.microsoft.com/dotnet/introducing-net-for-apache-spark/ &#xff0c;正印证了“微软在不断通过.NET Core补齐各领域开发&#xff0c;真正实现一种语言的跨平台”这句话。那么我们今天就…

Codeforces Round #760 (Div. 3)

E. Singers’ Tour F. Reverse G. Trader Problem 推推式子就行了。 int a[N]; int main() {int t;scanf("%d", &t);while(t --){int n;LL sum 0;scanf("%d", &n);for(int i 1;i < n;i ) scanf("%d", ai), sum a[i];a[0] a[n]…

acwing3132. 食物(BZOJ3028)

acwing3132. 食物 题意&#xff1a; 你当然要帮他计算携带 N 件物品的方案数。 承德汉堡&#xff1a;偶数个。 可乐&#xff1a;0 个或 1 个。 鸡腿&#xff1a;0 个&#xff0c;1 个或 2 个。 蜜桃多&#xff1a;奇数个。 鸡块&#xff1a;4 的倍数个。 包子&#xff1a;0 个…

持续畅销20年的《C#高级编程》出第11版了!

TA是谁&#xff1f;Wrox精品红皮书&#xff0c;引领无数程序员进入程序开发殿堂&#xff0c;C#专家级指南&#xff0c;是经验丰富的程序员提高效率的更快捷方式&#xff0c;连续畅销20年&#xff0c;累计销量超30万册。TA出生名门&#xff1a;TA战绩辉煌&#xff1a;2019新的征…

cfF. Boring Queries

cfF. Boring Queries 题意&#xff1a; n个数组a[]&#xff0c;q个询问&#xff0c;每次询问区间[l,r]的lcm值 题目要求强制在线 1<n<1e5 1<a<2e5 1<q<1e5 题解&#xff1a; 添加链接描述 添加链接描述 添加链接描述 我们一般求lcm都是直接通过ab/gcd(a…

Educational Codeforces Round 119 (Rated for Div. 2)

D. Exact Change E. Replace the Numbers G. Subsequences Galore 因为1和2的数量最大值不是很多&#xff0c;多了的话可以用3代替&#xff0c;那么枚举1和2的数量然后二分3的数量 int a[110], n; bitset<10> bit; bool ch(int x) {for(int i 1;i < n;i ){int num …

.NET微服务体系结构中为什么使用Ocelot实现API网关

为什么要使用API网关而不是直接通信&#xff1f;在微服务架构中&#xff0c;客户端应用程序通常需要使用来自多个微服务的功能。如果直接执行该消费&#xff0c;则客户端需要处理多个微服务端点以进行呼叫。当应用程序发展并引入新的微服务或更新现有的微服务时会发生什么&…

P2000 拯救世界

P2000 拯救世界 题意&#xff1a; 为了拯救世界&#xff0c;小 a 和 uim 决定召唤出 kkksc03 大神和 lzn 大神。根据古籍记载&#xff0c;召唤出任何一位大神&#xff0c;都需要使用金木水火土五种五行神石来摆一个特定的大阵。而在古籍中&#xff0c;记载是这样的&#xff1…