[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个节点的颜色不能相同 的情况下进行染色 ...
随机推荐
- repr() 和 str() 函数
这两个函数都是可以用来将值转换成字符串的. 函数str() 用于将值转化为适于人阅读的形式,而repr() 转化为供解释器读取的形式. 结果是:
- openlayer ol.js和ol-debug.js的使用 调试技巧
二者实现的功能是一样的,有以下区别 : ol.js一般打包项目的时候使用, ol-debug.js编写代码调试的时候使用. 下边是用ol-debug.js编写代码调试的显示: 编写代码调试的技巧,所有 ...
- mathType换行等号对齐
例如: 输入步骤: (1) (2) (3) (4) 事实上,[ctrl+;]表示的是插入了一个对齐标记符.
- 宠物属性控制_pet
classIndex 职业索引 DmgAddPct 根据职业的法伤或攻强来计算宠物增加的物理伤害,增加的伤害值等于玩家法伤或攻强的百分比 SpAddPct 根据职业的法伤或攻强来计算宠物增加的法术伤害 ...
- hdu 6169 Senior PanⅡ Miller_Rabin素数测试+容斥
Senior PanⅡ Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others) Pr ...
- lombok-@Accessors注解
@Accessors 有3个选项:如图默认是false 1.当fluent = true时 2.当fluent = true时
- SqlServer 中的触发器
SqlServer 触发器实现多表之间同步增加.删除与更新 定义: 何为触发器?在SQL Server里面也就是对某一个表的一定的操作,触发某种条件,从而执行的一段程序.触发器是一个特殊的存储过程. ...
- The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
关于出现这个·问题的原因貌似也是多种多样的? 在stack overflow上的帖子如下:https://stackoverflow.com/questions/43186315/tomcat-404 ...
- 虹软2.0免费离线人脸识别 Demo [C++]
环境: win10(10.0.16299.0)+ VS2017 sdk版本:ArcFace v2.0 OPENCV3.43版本 x64平台Debug.Release配置都已通过编译 下载地址:http ...
- cocos2dx spine之一 :spine缓存 (c++ & lua)
cocos2dx版本为3.10 1.在使用spine的过程中,发现了一个比较严重的问题:每次创建SkeletonAnimation的时候都会很卡,即使是使用同一个骨骼数据skeletonData. 跟 ...