[contest 782] 9.7
[contest 782] 9.7 - XJOI
个人觉得温暖题啊,,,可是卡毛空间呀!!!
T1 传送
线性筛预处理,然后一遍BFS。显然,这个BFS是O(n)的,主要要卡的就是预处理。
code:
%:pragma gcc optimize() #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; ; int L,R,n,H,T; ],cnt; bool isp[N]; int Q[N],f[N]; short D[N]; void Maker(){ memset(isp,,]=isp[]=; memset(p,,,D[]=; ; i<N; i++){ ; ; j<=cnt&&(long long)i*p[j]<N; j++){ isp[i*p[j]]=; ){ ; ) c++,now/=p[j]; D[i*p[j]]=D[i]/(c+)*(c+); break; }else D[i*p[j]]=D[i]+D[i]; } } } )%N,Q[T]=x;} int main(){ Maker(); int Ts; scanf("%d",&Ts); for (; Ts; Ts--){ scanf("%d%d%d",&L,&R,&n); memset(Q,,,T=,Q[]=L; memset(f,,; int x,y; if (L!=R) while (H!=T){ H=(H+)%N,x=Q[H],y=D[x]; if (x==R) break; if (x+y<=n){ ) f[x+y]=f[x]+,pus(x+y); } ){ ) f[x-y]=f[x]+,pus(x-y); } } printf("%d\n",f[R]); } ; }
T2 异或
一眼就是字典树,然而我把ch数组初值赋了-1然后计数时出现了一些奇妙的事情。。。
事实上,ai^x<=lim这是没有不等式规律的,然而,我们可以把他按位来计算,字典树就很有作用了。
复杂度大概是O(30n)。
code:
#include<cstdio> #include<cstring> #include<algorithm> #define M(a,x) memset(a,x,sizeof a) #define jug(i,x) (((1<<i)&x)>0) using namespace std; ; int n,m,a[N]; struct Trie{ ][],va[N*]; void init(){ siz=,M(ch,),M(va,); } void insert(int x){ ; ; i>=; i--){ bool c=jug(i,x); if (!ch[u][c]) ch[u][c]=++siz; u=ch[u][c],va[u]++; } } int query(int x,int lim){ ) ; ,ret=n; ; i>=; i--){ bool v=jug(i,x),w=jug(i,lim); ) ret-=va[ch[u][-(w^v)]]; u=ch[u][w^v]; } return ret; } }t; inline int read(){ ; char ch=getchar(); ') ch=getchar(); +ch-',ch=getchar(); return x; } int main(){ n=read(),m=read(),t.init(); ; i<=n; i++) a[i]=read(),t.insert(a[i]); for (; m; m--){ int x=read(),L=read(),R=read(); printf()); } ; }
T3 棋盘
md,看到这题就想表一下。为什么要卡16MB!!!
还不是因为我手贱将f[1<<20]“细心地”变成f[1<<21],然后爆了0.39M内存。。。
好吧,这就是个状压DP,真的水。
code:
%:pragma gcc optimize() #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #define LL long long using namespace std; ; ][]; <<]; LL ans; int main(){ scanf(<<n); ; i<n; i++) scanf("%s",G[i]); memset(f,,sizeof f); ; i<n; i++) ][i]==<<i]=; ; r<n; r++){ ; j--) ; i<n; i++) <<i)&j)==) f[j|(<<i)]=((LL)f[j|(<<i)]+f[j])%TT; ; i<n; i++) <<i]++; } ; j<M; j++){ ; ; i<n; i++) <<i)&j) c++; if (c==k) ans=(ans+f[j])%TT; } printf("%lld",ans%TT); ; }
总而言之,题目不难,限制变态。。。
[contest 782] 9.7的更多相关文章
- Codeforces 782C. Andryusha and Colored Balloons 搜索
C. Andryusha and Colored Balloons time limit per test:2 seconds memory limit per test:256 megabytes ...
- 树的性质和dfs的性质 Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) E
http://codeforces.com/contest/782/problem/E 题目大意: 有n个节点,m条边,k个人,k个人中每个人都可以从任意起点开始走(2*n)/k步,且这个步数是向上取 ...
- 2-sat Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) D
http://codeforces.com/contest/782/problem/D 题意: 每个队有两种队名,问有没有满足以下两个条件的命名方法: ①任意两个队的名字不相同. ②若某个队 A 选用 ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) E Underground Lab
地址:http://codeforces.com/contest/782/problem/E 题目: E. Underground Lab time limit per test 1 second m ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) D. Innokenty and a Football League
地址:http://codeforces.com/contest/782/problem/D 题目: D. Innokenty and a Football League time limit per ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) C Andryusha and Colored Balloons
地址:http://codeforces.com/contest/782/problem/C 题目: C. Andryusha and Colored Balloons time limit per ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) B. The Meeting Place Cannot Be Changed
地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) A. Andryusha and Socks
地址:http://codeforces.com/contest/782/problem/A 题目: A. Andryusha and Socks time limit per test 2 seco ...
- 【codeforces 782C】Andryusha and Colored Balloons
[题目链接]:http://codeforces.com/contest/782/problem/C [题意] 给你一棵树 让你满足要求 ->任意相连的3个节点的颜色不能相同 的情况下进行染色 ...
随机推荐
- python3.6配置libsvm2.2
参考自:https://blog.csdn.net/weixin_35884839/article/details/79398085 由于需要使用到libsvm,所以开始配这个,所幸一次性就成功了. ...
- Spring数据库连接池依赖
<!-- https://mvnrepository.com/artifact/c3p0/c3p0 --> <dependency> <groupId>c3p0&l ...
- URL helper 逆向破解思路+详细过程 利用messagebox破解
先了解一下软件的运行: 打开后是这样的,要注册 随便输入假注册码,看他怎么响应: 会弹出一个信息窗(massageBox)提示注册失败.到这里就行了,关掉,然后用OD打开,按F9跑起来: 这里输入假码 ...
- _event
EventId 事件ID 请使用大于100的ID EventName 事件的名称,用于游戏中各种提示 NoticeText 事件开始时的弹窗内容 GossipText 功能宝石等菜单内容 Z ...
- go 内嵌对象类型
demo1 // Sample program to show how to embed a type into another type and // the relationship betwee ...
- 三: 爬虫之selenium模块
一 selenium模块 什么是selenium?selenium是Python的一个第三方库,对外提供的接口可以操作浏览器,然后让浏览器完成自动化的操作. selenium最初是一个自动化测试工具, ...
- 串口.Qt532测试(同步)
环境:Win7x64.Qt5.3.2 MSVC OpenGL(x86).vs2010(x86) ZC:这里的例子是 同步的函数操作,貌似 如果子线程在等待 WaitCommEvent(...)或Rea ...
- HTML5语义化
转载自:https://www.cnblogs.com/fliu/articles/5244866.html 1.什么是HTML语义化? 用合理.正确的标签来展示内容,比如h1~h6定义标题,便于开发 ...
- echarts 拼图和折线图的封装 及常规处理
1.html <div id="wrap"></div> 2.js ; (function ($) { $.fn.extend({ echartsPie: ...
- mint18.3 升级linux-libc-dev_4.4.0-102.132 导致外接显示屏无法旋转,设置分辨率
—————————————————— 补记: 虽然修改之后能旋转,重启还是不行,而且修改显示,经常卡死.还是在第二天早上重装了. 吸取教训,尽量不apt dist-upgrade,不升级内核. 这只是 ...