[contest 782] 9.7 - XJOI

个人觉得温暖题啊,,,可是卡毛空间呀!!!

T1 传送

KXv3irV2idC98WYQBSgkt5akubMMKgdXP6FA3acJ

UbACBgBI2AEjEAPERhCyOgWKZuEe4i0VRkBI2AEj

线性筛预处理,然后一遍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 异或

weWmVaOx2KcHQAAAABJRU5ErkJggg==

AAAAAElFTkSuQmCC

一眼就是字典树,然而我把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 棋盘

rFGHaKtyaVHzcGvXri2uvfbaqmj6SUACEpCABCQg

w8LKUC13ZFlnAAAAABJRU5ErkJggg==

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的更多相关文章

  1. Codeforces 782C. Andryusha and Colored Balloons 搜索

    C. Andryusha and Colored Balloons time limit per test:2 seconds memory limit per test:256 megabytes ...

  2. 树的性质和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步,且这个步数是向上取 ...

  3. 2-sat Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) D

    http://codeforces.com/contest/782/problem/D 题意: 每个队有两种队名,问有没有满足以下两个条件的命名方法: ①任意两个队的名字不相同. ②若某个队 A 选用 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 【codeforces 782C】Andryusha and Colored Balloons

    [题目链接]:http://codeforces.com/contest/782/problem/C [题意] 给你一棵树 让你满足要求 ->任意相连的3个节点的颜色不能相同 的情况下进行染色 ...

随机推荐

  1. [0412]SQL Server 2008 R2 安装 & 设置

    SQL Server 2008 R2 安装 & 设置 Sql Server 安装 安装环境: Windows 10 1709 64位 安装文件: Sql Server 2008 R2 Sql ...

  2. 使用R语言的RTCGA包获取TCGA数据--转载

    转载生信技能树 https://mp.weixin.qq.com/s/JB_329LCWqo5dY6MLawfEA TCGA数据源 - R包RTCGA的简单介绍 - 首先安装及加载包 - 指定任意基因 ...

  3. CSDN-markdown编辑器语法——字体、字号与颜色

     Markdown是一种可以使用普通文本编辑器编写的标记语言,通过类似HTML的标记语法,它可以使普通文本内容具有一定的格式.但是它本身是不支持修改字体.字号与颜色等功能的!   CSDN-markd ...

  4. codeforces 767C - Garland

    题目链接:http://codeforces.com/contest/767/problem/C 问能否将一棵带点权的书分成点权$3$块,求任意方案. 其实考虑一棵以$x$为根的子树权值为${\fra ...

  5. python 定时器

    2s启动一个定时器: import threading import time def hello(name): print "hello %s\n" % name global ...

  6. 正则获取 某段 DIV 中 的内容

    string html = "<div class='aa'><div class='left'>324324<div>dsfsdf</div> ...

  7. git difftool和mergetool图形化

    1.当然是先安装Beyond Compare3 (此处省略安装步骤,自行百度) 2.设置difftool git config --global diff.tool bc3 git config -- ...

  8. vue模板编译

    Vue 的模板编译是在 $mount 的过程中进行的,在 $mount 的时候执行了 compile 方法来将 template 里的内容转换成真正的 HTML 代码. complie 最终生成 re ...

  9. sort-归并排序

    void sort_merge(vector<int> &v,int left,int right) { if(left>=right) return; int mid=(l ...

  10. 学习笔记24—win10环境下python版libsvm的安装

    1.前言 由于毕业设计需要用到libsvm,所以最近专心于配置libsvm,曾经尝试过在matlab中安装,但是没有成功.最终在Python环境中完成安装. 2.LIBSVM介绍 LIBSVM 是台湾 ...