[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. Quartus工程中各文件类型的含义

    https://blog.csdn.net/jingliangliu/article/details/52245497 .jic           JTAG Indirect Configurati ...

  2. webpack插件配置(二)- HtmlWebpackPlugin

    作用 简化Html文件的创建,以便为你的webpack bundle包提供服务.这对于在文件名中包含每次会随着编译而发生变化的hash的webpack bundle尤其有用.插件可以生成一个HTML文 ...

  3. unity3d 加载优化建议 总结 from 侑虎科技

    第一部分 我们对于纹理资源的加载建议如下: 1.严格控制RGBA32和ARGB32纹理的使用,在保证视觉效果的前提下,尽可能采用“够用就好”的原则,降低纹理资源的分辨率,以及使用硬件支持的纹理格式. ...

  4. 由设置body线性背景色引发的问题-----当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡

    问题:当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡 不声明文档类型时,对body设置线性背景色 <HTML> <head> <meta char ...

  5. python requests post和get

    import requests import time import hashlib import os import json from contextlib import closing impo ...

  6. matplotlib.transforms

    来自:龙哥盟飞龙 变换教程 像任何图形包一样,matplotlib建立在变换框架之上,以便在坐标系,用户数据坐标系,轴域者坐标系,图形坐标系和显示坐标系之间轻易变换.在95%的绘图中,你不需要考虑这一 ...

  7. Boostrap本地导入js文件

    我一般都是用CDN直接导入的,但是有时候需要自己添加一些功能进入,会用到本地导入.关于导入路径问题,做个笔记. 使用HBuilder,首先右键导入相应的js/cs文件 然后是常规——>文件系统 ...

  8. CentOS7.6 如何设置静态ip

    [root@localhost network-scripts]# cd /etc/sysconfig/network-scripts/[root@localhost network-scripts] ...

  9. (转)C# 的 String.CompareTo、 Equals和==的比较

    String.CompareTo 语法 public int CompareTo(    string strB) 返回值 小于 0,实例小于参数 strB: 0,实例等于参数 strB: 大于 0, ...

  10. 用 EasyUEFI 在 Win8/10 中硬盘安装 Ubuntu16.04图文教程

    用 EasyUEFI 在 Win8/10 中硬盘安装 Ubuntu 作者:TeliuTe 来源:基础教程网 1.准备Ubuntu安装文件 1)下载带amd的64位 Ubuntu 桌面版光盘镜像文件,如 ...