前言

如您所见这又是一篇咕了的文章,直接咕了10天

好久没打CF了 所以还是个蓝名菜鸡

机房所有人都紫名及以上了,wtcl

这次前4题这么水虽然不知道为什么花了1h,结果不知道为什么搞到一半出锅了,后面直接unrated了qwq

虽然如果是rated我就掉成newbie了

A

题意

在一个矩阵中统计\(a_{i,j}=a_{i-1,j-1}=a_{i-1,j+1}=a_{i+1,j-1}=a_{i+1,j+1}='X'\)

题解

sbt

B

题意

有n种菜,每种菜有价格和数量,然后依次会来m个客人,依次服务每个客人,每个客人需要一定数量的某个菜,如果有就给他,如果他要的菜没有就每次给他最便宜的中编号最小的菜,如果没有菜他就吃菜不付钱.问每个人交多少钱

题解

用set维护菜,价格第一关键字,编号第二关键字,然后模拟

C

题意

n个数(n为偶数),要分组,每组不少于两个数,每组价值为元素和的平方,求最小价值和

题解

显然两个数一组,同时显然排完序后每次从两边各拿一个数凑成一组

D

题意

给一个图,从1号点出发遍历这个图(随便遍历),第一次走到某个点就把编号加入一个序列,问最小字典序序列

题解

不知道比NOIPD2T1水到哪去了

显然要从能走到的没走过的点里选一个编号最小的走,用堆维护即可

E

题意

有k个红包,每个可以在\([l_i,r_i]\)时间里取到,如果取这个红包就得到一定收益,同时往后走直到\(d_i+1\)时刻才能继续取红包\((l_i\le r_i\le d_i)\)

现在贪心取红包,如果在某个时刻能取红包,那么就取价值最大中d最大的红包

现在可以骚扰m次,在时刻x骚扰会导致x时刻无法取红包,问最少取多少收益

题解

这题就是个dp啊,为什么我不去做呢qwq

首先因为\(r_i\le d_i\),所以每个时间点取红包都是唯一的,不会相互影响.用set预处理出每个时间点取那个红包.可以发现每个红包可以看成一个\([i,d_i]\)有收益的线段,然后可以插入m个长度为1收益为0线段,然后依次填满时间段,问最小代价.设\(f[i][j]\)表示做到时刻i,骚扰j次,转移枚举下一位骚扰或不骚扰即可

然而我做的时候各种细节没考虑,交了1h

  1. #include<bits/stdc++.h>
  2. #define LL long long
  3. #define db double
  4. #define il inline
  5. #define re register
  6. using namespace std;
  7. const int N=1e5+10;
  8. il int rd()
  9. {
  10. int x=0,w=1;char ch=0;
  11. while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
  12. while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
  13. return x*w;
  14. }
  15. struct node
  16. {
  17. int l,r,d,x;
  18. bool operator < (const node &bb) const {return x!=bb.x?x<bb.x:d<bb.d;}
  19. }a[N<<1];
  20. il bool cmp(node a,node b){return a.l<b.l;}
  21. int n,m,kk;
  22. LL f[N][210],inf=1ll<<50;
  23. priority_queue<node> q;
  24. int main()
  25. {
  26. //wtcl
  27. n=rd(),m=rd(),kk=rd();
  28. for(int i=1;i<=kk;++i) a[i].l=rd(),a[i].r=rd(),a[i].d=rd(),a[i].x=rd();
  29. for(int i=1;i<=n;++i) ++kk,a[kk].l=a[kk].r=a[kk].d=i,a[kk].x=0;
  30. sort(a+1,a+kk+1,cmp);
  31. memset(f,0x3f3f3f,sizeof(f));
  32. f[0][0]=0;
  33. for(int i=1,o=1;i<=n;++i)
  34. {
  35. while(a[o].l==i) q.push(a[o++]);
  36. while(!q.empty()&&q.top().r<i) q.pop();
  37. int d=n+1,x=inf;
  38. if(!q.empty()) d=q.top().d,x=q.top().x;
  39. for(int j=0;j<=m;++j)
  40. {
  41. f[i][j+1]=min(f[i][j+1],f[i-1][j]);
  42. f[d][j]=min(f[d][j],f[i-1][j]+x);
  43. }
  44. }
  45. LL ans=inf;
  46. for(int j=0;j<=m;++j) ans=min(ans,f[n][j]);
  47. cout<<ans<<endl;
  48. return 0;
  49. }

F

题意

一个数列,\(f_1=f_2=...=f_{k-1}=1,f_n=m\),并且\(f_i=\prod_{j=1}^{k}{f_{i-j}}^{b_j}\),问\(f_k\)

题解

首先通过手玩可以发现式子可以转化成\({f_k}^a=f_n=m\),然后这个k是可以矩乘求出的(怎么求自己玩去).注意到模数为998244353,原根为3,可以考虑原根,即设\(f_k=g^x,m=g^y\),原式变为\(g^{ax}=g^y(mod\ 998244353)\),根据欧拉定理,这等价于\(ax=y(mod\ 998244352)\),然后y可以bsgs求,x可以exgcd求

注意欧拉定理,矩乘模数是原模数-1

我这种菜鸡什么板子都写错,pp都pp不了

  1. #include<bits/stdc++.h>
  2. #define LL long long
  3. #define il inline
  4. #define re register
  5. #define db double
  6. using namespace std;
  7. const int N=700+10,mod=998244353,g=3;
  8. il LL rd()
  9. {
  10. LL x=0,w=1;char ch=0;
  11. while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
  12. while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
  13. return x*w;
  14. }
  15. map<int,int> ha;
  16. il LL fpow(LL a,LL b){LL an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
  17. il LL bsgs(LL a,LL b)
  18. {
  19. ha.clear();
  20. LL kk=sqrt(mod)+1,aa=b,ka=fpow(a,kk);
  21. for(int i=0;i<kk;++i) ha[aa]=i,aa=aa*a%mod;
  22. aa=1;
  23. for(int i=0;i<=kk;++i)
  24. {
  25. if(ha.find(aa)!=ha.end()&&i*kk-ha[aa]>=0) return i*kk-ha[aa];
  26. aa=aa*ka%mod;
  27. }
  28. return -1;
  29. }
  30. int n,m,kk,b[110];
  31. struct martix
  32. {
  33. int n,m;
  34. int a[110][110];
  35. martix(){}
  36. il void init()
  37. {
  38. for(int i=1;i<=n;i++) a[i][i]=1;
  39. }
  40. martix(int n,int m):n(n),m(m)
  41. {
  42. for(int i=1;i<=n;i++)
  43. for(int j=1;j<=m;j++)
  44. a[i][j]=0;
  45. }
  46. martix operator * (const martix &b) const
  47. {
  48. martix an(n,b.m);
  49. for(int i=1;i<=n;i++)
  50. for(int j=1;j<=m;j++)
  51. for(int k=1;k<=b.m;k++)
  52. an.a[i][j]=(an.a[i][j]+1ll*a[i][k]*b.a[k][j]%(mod-1))%(mod-1);
  53. return an;
  54. }
  55. martix operator ^ (const LL &bb) const
  56. {
  57. martix a=*this,an(a.n,a.m);
  58. an.init();
  59. LL b=bb;
  60. while(b)
  61. {
  62. if(b&1) an=an*a;
  63. a=a*a,b>>=1;
  64. }
  65. return an;
  66. }
  67. }ma,mb;
  68. il void exgcd(LL a,LL b,LL &d,LL &x,LL &y)
  69. {
  70. if(!b){d=a,x=1,y=0;return;}
  71. exgcd(b,a%b,d,y,x),y-=a/b*x;
  72. }
  73. int main()
  74. {
  75. n=rd();
  76. for(int i=1;i<=n;++i) b[i]=rd();
  77. kk=rd(),m=rd();
  78. ma.n=ma.m=mb.n=mb.m=n;
  79. ma.a[1][n]=1;
  80. for(int i=1;i<n;++i) mb.a[i+1][i]=1;
  81. for(int i=1;i<=n;++i) mb.a[n-i+1][n]=b[i]%(mod-1);
  82. ma=ma*(mb^(kk-n));
  83. LL bb=bsgs(g,m),x,y,d;
  84. //cout<<ma.a[1][n]<<endl;sgllsjlg
  85. //cout<<bb<<endl;
  86. if(bb==-1) return puts("-1"),0;
  87. exgcd(ma.a[1][n],mod-1,d,x,y);
  88. //cout<<d<<endl;
  89. if(bb%d) return puts("-1"),0;
  90. y=(mod-1)/d;
  91. //cout<<x<<endl;
  92. x=(1ll*(x%y+y)%y*(bb/d)%y+y)%y;
  93. printf("%d\n",(int)fpow(g,x));
  94. return 0;
  95. }

Codeforces Round #536 (Div. 2)的更多相关文章

  1. Codeforces Round 536 (Div. 2) (E)

    layout: post title: Codeforces Round 536 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  2. Codeforces Round #536 (Div. 2) F 矩阵快速幂 + bsgs(新坑) + exgcd(新坑) + 欧拉降幂

    https://codeforces.com/contest/1106/problem/F 题意 数列公式为\(f_i=(f^{b_1}_{i-1}*f^{b_2}_{i-2}*...*f^{b_k} ...

  3. Codeforces Round #536 (Div. 2) E dp + set

    https://codeforces.com/contest/1106/problem/E 题意 一共有k个红包,每个红包在\([s_i,t_i]\)时间可以领取,假如领取了第i个红包,那么在\(d_ ...

  4. Codeforces Round #536 (Div. 2)--1106D - Lunar New Year and a Wander

    https://codeforces.com/contest/1106/problem/D 题意:求出字典序最小的走法 解法:走到每个点,都选取与这个点连通的序号最小的点,并且这个序号最小的点没有被访 ...

  5. Codeforces Round #536 (Div. 2) B. Lunar New Year and Food Ordering

    #include <bits/stdc++.h> #define N 300010 #define PII pair<int, int> using namespace std ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. Git中撤销提交

    Git的几种状态 未修改 原始内容 已修改 ↓ 工 作 区 已暂存 ↓ git add 暂 存 区 已提交 ↓ git commit 本地仓库 已推送 ↓ git push 远程仓库 注意:下面所有命 ...

  2. Windows下VMware14黑屏

    解决方法 以管理员身份运行命令提示符,执行netsh winsock reset

  3. python的异步IO模块

    asyncio模块:示例一 import asyncio @asyncio.coroutine def func1(): print('before...func1......') yield fro ...

  4. javascript学习笔记二

    1.js的string对象 **创建 String对象 *** var str = "abc"; **方法 和 属性(文档) *** 属性 length : 字符串的长度 ***方 ...

  5. Day037--Python--线程的其他方法,GIL, 线程事件,队列,线程池,协程

    1. 线程的一些其他方法 threading.current_thread()  # 线程对象 threading.current_thread().getName()  # 线程名称 threadi ...

  6. c#中内置委托

    一.Action泛型委托 和之前委托最大区别在于不用定义委托,直接实例化委托(申明就可以),泛型其实就是选择数据类型,进行使得程序更加安全,并且也实现了委托的重载,最多选择16个参数. namespa ...

  7. SqlServer查询Excel中的数据

    步骤如下: --1.开启远程查询支持 reconfigure reconfigure --2.链接Excel Microsoft ACE 12.0 OLE DB Provider 读Excel数据(注 ...

  8. puppeteer端对端测试demo

    1. 下载pupperteer npm i puppeteer 2. 启动一个本地服务 localhost 3. 开启测试 const puppeteer = require('puppeteer') ...

  9. sklearn-woe/iv-乳腺癌分类器实战

    sklearn实战-乳腺癌细胞数据挖掘 https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campai ...

  10. MySQL语句_积累

    1.GROUP_CONCAT 直接返回拼接好的多个结果,可以供IN()函数使用 语句 结果 +-----------------------------------------+ | GROUP_CO ...