NOIP模拟赛11
T1 [HAOI2016]放棋子
https://daniu.luogu.org/problem/show?pid=3182
障碍交换行不影响
所以第i列有障碍的行换到第i行
然后错排公式
本校自测要写压位高精,不写了。。。
- #include<cstdio>
- #include<cstring>
- #include<algorithm>
- using namespace std;
- struct node
- {
- int len;
- int num[];
- void clear()
- {
- len=;
- memset(num,,sizeof(num));
- }
- void operator = (int a)
- {
- len=;
- while(a) len++,num[len]=a%,a/=;
- }
- void operator = (node a)
- {
- len=a.len;
- for(int i=;i<=len;i++) num[i]=a.num[i];
- }
- node operator + (node a)
- {
- node c; c.clear();
- memset(c.num,,sizeof(c.num));
- int L=max(a.len,len);
- c.len=L;
- for(int i=;i<=L;i++) c.num[i]=num[i]+a.num[i];
- for(int i=;i<=L;i++)
- if(c.num[i]>) c.num[i+]+=c.num[i]/,c.num[i]%=;
- if(c.num[L+]) c.len++;
- while(c.num[c.len]>) c.num[c.len+]=c.num[c.len]/,c.num[c.len]%=,len++;
- if(c.num[c.len+]) c.len++;
- return c;
- }
- node operator * (int a)
- {
- node c; c.clear();
- int L;
- c.len=L=len;
- for(int i=;i<=L;i++) c.num[i]=num[i]*a;
- for(int i=;i<=L;i++)
- if(c.num[i]>) c.num[i+]+=c.num[i]/,c.num[i]%=;
- if(c.num[L+]) c.len++;
- while(c.num[c.len]>) c.num[c.len+]=c.num[c.len]/,c.num[c.len]%=,len++;
- if(c.num[c.len+]) c.len++;
- return c;
- }
- void print()
- {
- for(int i=len;i;i--) printf("%d",num[i]);
- }
- };
- node f[];
- int main()
- {
- // freopen("firstmeet.in","r",stdin);
- // freopen("firstmeet.out","w",stdout);
- int n;
- scanf("%d",&n);
- f[]=,f[]=,f[]=;
- for(int i=;i<=n;i++)
- {
- f[i].clear();
- f[i]=(f[i-]+f[i-])*(i-);
- }
- f[n].print();
- }
T2 [Usaco2010 Dec]Exercise 奶牛健美操
http://www.lydsy.com/JudgeOnline/problem.php?id=2097
树形DP
- #include<cstdio>
- #include<cstring>
- #include<iostream>
- #include<algorithm>
- #define N 100001
- using namespace std;
- int front[N],to[N<<],nxt[N<<],tot;
- int dp[N],tmp[N];
- int cnt,p;
- void read(int &x)
- {
- x=; char c=getchar();
- while(!isdigit(c)) c=getchar();
- while(isdigit(c)) { x=x*+c-''; c=getchar(); }
- }
- void add(int u,int v)
- {
- to[++tot]=v; nxt[tot]=front[u]; front[u]=tot;
- to[++tot]=u; nxt[tot]=front[v]; front[v]=tot;
- }
- bool dfs(int x,int y,int z)
- {
- int sum=;
- for(int i=front[x];i;i=nxt[i])
- if(to[i]!=y) { if(!dfs(to[i],x,z)) return false; }
- for(int i=front[x];i;i=nxt[i])
- if(to[i]!=y) tmp[++sum]=dp[to[i]]+;
- sort(tmp+,tmp+sum+);
- for(sum;tmp[sum]+tmp[sum-]>z;sum--,cnt++);
- dp[x]=tmp[sum];
- if(cnt>p) return false;
- return true;
- }
- bool check(int mid)
- {
- memset(dp,,sizeof(dp));
- cnt=;
- return dfs(,,mid);
- }
- int main()
- {
- /* int size = 256 << 15;
- char *pp = (char*) malloc(size) + size;
- __asm__ ("movl %0, %%esp\n" :: "r"(pp));
- freopen("longnosee.in","r",stdin);
- freopen("longnosee.out","w",stdout); */
- int n;
- read(n), read(p);
- int u,v;
- for(int i=;i<n;i++)
- {
- read(u),read(v);
- add(u,v);
- }
- int l=,r=n,mid,ans;
- while(l<=r)
- {
- mid=l+r>>;
- if(check(mid)) ans=mid,r=mid-;
- else l=mid+;
- }
- printf("%d",ans);
- }
T3
大爆搜,粘std啦
- #include <cstdio>
- #include <iostream>
- #define rg register
- #define Max 22
- inline void read (int &now)
- {
- rg char c = getchar ();
- for (now = ; !isdigit (c); c = getchar ());
- for (; isdigit (c); now = now * + c - '', c = getchar ());
- }
- int _x[] = { , -, , , , }, _y[] = { , , , -, , }, _z[] = { , , , , , - };
- int N, M, Z, P, Sx, Sy, Sz, St, Tt,Tx, Ty, Tz, Answer; bool is[Max][Max][Max], dot[Max][Max][Max];
- inline bool Can (int x, int y, int z) { return x > && x <= N && y > && y <= M && z > && z <= Z && !is[x][y][z] && !dot[x][y][z]; }
- inline int abs (int a) { return a < ? -a : a; }
- void Dfs (int x, int y, int z, int t, int s)
- {
- int r = abs (x - Tx) + abs (y - Ty) + abs (z - Tz);
- if (s + (r >> ) >= Answer) return ;
- if (x == Tx && y == Ty && z == Tz) { if (t == Tt) Answer = s; return ; }
- rg int i, a, b, c;
- if (Can (x + _x[t], y + _y[t], z + _z[t]) && Can (x + _x[t] * , y + _y[t] * , z + _z[t] * ))
- {
- is[x + _x[t]][y + _y[t]][z + _z[t]] = true;
- is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = true;
- for (i = ; i < ; ++ i)
- if ((i >> ) != (t >> ) && Can (a + _x[i], b + _y[i], c + _z[i]) && Can (a + _x[i] * , b + _y[i] * , c + _z[i] * ))
- {
- is[a + _x[i]][b + _y[i]][c + _z[i]] = true;
- is[a + _x[i] * ][b + _y[i] * ][c + _z[i] * ] = true;
- Dfs (a + _x[i] * , b + _y[i] * , c + _z[i] * , i, s + );
- is[a + _x[i]][b + _y[i]][c + _z[i]] = false;
- is[a + _x[i] * ][b + _y[i] * ][c + _z[i] * ] = false;
- }
- if (Can (x + _x[t] * , y + _y[t] * , z + _z[t] * ))
- {
- is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = true;
- for (i = ; i < ; ++ i)
- if ((i >> ) != (t >> ) && Can (a + _x[i], b + _y[i], c + _z[i]))
- {
- is[a + _x[i]][b + _y[i]][c + _z[i]] = true;
- Dfs (a + _x[i], b + _y[i], c + _z[i], i, s + );
- is[a + _x[i]][b + _y[i]][c + _z[i]] = false;
- }
- is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = false;
- }
- is[x + _x[t]][y + _y[t]][z + _z[t]] = false;
- is[x + _x[t] * ][y + _y[t] * ][z + _z[t] * ] = false;
- }
- }
- int Main ()
- {
- freopen ("blessyou.in", "r", stdin); freopen ("blessyou.out", "w", stdout);
- read (N), read (M), read (Z), read (P); rg int i, j; int x, y, z; rg char c;
- if (N <= && M <= && Z <= ) return printf ("Dream Battle"), ;
- read (Sx), read (Sy), read (Sz);
- for (c = getchar (); c != 'x' && c != 'y' && c != 'z'; c = getchar ());
- St = (c - 'x') << ;
- if (c == 'x') St += (Sx == N); else if (c == 'y') St += (Sy == M);
- else if (c == 'z') St += (Sz == Z);
- Sx -= _x[St], Sy -= _y[St], Sz -= _z[St];
- read (Tx), read (Ty), read (Tz);
- for (c = getchar (); c != 'x' && c != 'y' && c != 'z'; c = getchar ());
- Tt = (c - 'x') << ;
- if (c == 'x') Tt += (Tx == ); else if (c == 'y') Tt += (Ty == );
- else if (c == 'z') Tt += (Tz == );
- for (i = ; i <= P; ++ i) read (x), read (y), read (z), dot[x][y][z] = true;
- Answer = ; Dfs (Sx, Sy, Sz, St, );
- if (Answer == ) printf ("Dream Battle"); else printf ("%d", Answer);
- return ;
- }
- int ZlycerQan = Main (); int main (int argc, char *argv[]) { return ; }
NOIP模拟赛11的更多相关文章
- 11/1 NOIP 模拟赛
11.1 NOIP 模拟赛 期望得分:50:实际得分:50: 思路:暴力枚举 + 快速幂 #include <algorithm> #include <cstring> #in ...
- NOIP模拟赛-2018.11.7
NOIP模拟赛 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 编译之前另存一份,听说如果敲 ...
- NOIP模拟赛-2018.11.6
NOIP模拟赛 今天想着反正高一高二都要考试,那么干脆跟着高二考吧,因为高二的比赛更有技术含量(我自己带的键盘放在这里). 今天考了一套英文题?发现阅读理解还是有一些困难的. T1:有$n$个点,$m ...
- NOIP模拟赛-2018.11.5
NOIP模拟赛 好像最近每天都会有模拟赛了.今天从高二逃考试跑到高一机房,然而高一也要考试,这回好像没有拒绝的理由了. 今天的模拟赛好像很有技术含量的感觉. T1:xgy断句. 好诡异的题目,首先给出 ...
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 10.17 NOIP模拟赛
目录 2018.10.17 NOIP模拟赛 A 咒语curse B 神光light(二分 DP) C 迷宫maze(次短路) 考试代码 B 2018.10.17 NOIP模拟赛 时间:1h15min( ...
- NOI.AC NOIP模拟赛 第三场 补记
NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...
随机推荐
- 解决Ubuntu16.04 fatal error: json/json.h: No such file or directory
参考博客 错误产生 安装json-c库之后,根据GitHub上面的readme文件链接到json-c库时出现以下错误: SDMBNJson.h:9:23: fatal error: json/json ...
- ubuntu下配置ss并设置PAC模式
一.安装ss 1. sudo apt-get update(更新源) 2. sudo apt-get install python-pip(安装pip) 3. sudo pip install sha ...
- BETA阶段第一天
1.提供当天站立式会议照片一张 2.每个人的工作 今天完成工作 林一心 服务器调试 张杭镖 数据库调整 赵意 前端设计 江鹭涛 前端设计 3.发布项目燃尽图 4.每日每人总结 林一心:服务器端的配置不 ...
- Windows Forms编程实战学习:第一章 初识Windows Forms
初识Windows Forms 1,用C#编程 using System.Windows.Forms; [assembly: System.Reflection.AssemblyVersion(& ...
- 敏捷冲刺DAY8
一. 每日会议 1. 照片 2. 昨日完成工作 第一次阶段测试. 3. 今日完成工作 对前七次敏捷冲刺的工作进行完善. 4. 工作中遇到的困难 浏览器兼容性问题.页面响应性能问题.内存溢出问题-- 二 ...
- 微信小程序组件 自定义单选
<view class='userperson'> <view class='f30 flexca'>请选择您的注册身份</view> <view class ...
- vue-cli3使用cdn方式引入moment.js
1. index.html引入: <script src="https://cdn.bootcss.com/moment.js/2.20.1/moment.min.js"&g ...
- PHP面向对象之重载
重载技术overloading 重载的基本概念 重载在“通常面向对象语言”中的含义: 是指,在一个类(对象)中,有多个名字相同但形参不同的方法的现象: 类似这样: class C{ functio ...
- Oracle schema 的含义
方案(Schema)为数据库对象的集合,为了区分各个集合,我们需要给这个集合起个名字,这些名字就是我们在企业管理器的方案下看到的许多类似用户名的节点,这些类似用户名的节点其实就是一个schema,sc ...
- 【Python】Python流程控制
1)if条件测试 Python的比较操作 所有的Python对象都支持比较操作 测试操作符('=='操作符测试值的相等性: 'is'表达式测试对象的一致性) Python中不同类型的比较方法 数字:通 ...