T1 [HAOI2016]放棋子

https://daniu.luogu.org/problem/show?pid=3182

障碍交换行不影响

所以第i列有障碍的行换到第i行

然后错排公式

本校自测要写压位高精,不写了。。。

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<algorithm>
  4. using namespace std;
  5. struct node
  6. {
  7. int len;
  8. int num[];
  9. void clear()
  10. {
  11. len=;
  12. memset(num,,sizeof(num));
  13. }
  14. void operator = (int a)
  15. {
  16. len=;
  17. while(a) len++,num[len]=a%,a/=;
  18. }
  19. void operator = (node a)
  20. {
  21. len=a.len;
  22. for(int i=;i<=len;i++) num[i]=a.num[i];
  23. }
  24. node operator + (node a)
  25. {
  26. node c; c.clear();
  27. memset(c.num,,sizeof(c.num));
  28. int L=max(a.len,len);
  29. c.len=L;
  30. for(int i=;i<=L;i++) c.num[i]=num[i]+a.num[i];
  31. for(int i=;i<=L;i++)
  32. if(c.num[i]>) c.num[i+]+=c.num[i]/,c.num[i]%=;
  33. if(c.num[L+]) c.len++;
  34. while(c.num[c.len]>) c.num[c.len+]=c.num[c.len]/,c.num[c.len]%=,len++;
  35. if(c.num[c.len+]) c.len++;
  36. return c;
  37. }
  38. node operator * (int a)
  39. {
  40. node c; c.clear();
  41. int L;
  42. c.len=L=len;
  43. for(int i=;i<=L;i++) c.num[i]=num[i]*a;
  44. for(int i=;i<=L;i++)
  45. if(c.num[i]>) c.num[i+]+=c.num[i]/,c.num[i]%=;
  46. if(c.num[L+]) c.len++;
  47. while(c.num[c.len]>) c.num[c.len+]=c.num[c.len]/,c.num[c.len]%=,len++;
  48. if(c.num[c.len+]) c.len++;
  49. return c;
  50. }
  51. void print()
  52. {
  53. for(int i=len;i;i--) printf("%d",num[i]);
  54. }
  55. };
  56. node f[];
  57. int main()
  58. {
  59. // freopen("firstmeet.in","r",stdin);
  60. // freopen("firstmeet.out","w",stdout);
  61. int n;
  62. scanf("%d",&n);
  63. f[]=,f[]=,f[]=;
  64. for(int i=;i<=n;i++)
  65. {
  66. f[i].clear();
  67. f[i]=(f[i-]+f[i-])*(i-);
  68. }
  69. f[n].print();
  70. }

T2  [Usaco2010 Dec]Exercise 奶牛健美操

http://www.lydsy.com/JudgeOnline/problem.php?id=2097

树形DP

  1. #include<cstdio>
  2. #include<cstring>
  3. #include<iostream>
  4. #include<algorithm>
  5. #define N 100001
  6. using namespace std;
  7. int front[N],to[N<<],nxt[N<<],tot;
  8. int dp[N],tmp[N];
  9. int cnt,p;
  10. void read(int &x)
  11. {
  12. x=; char c=getchar();
  13. while(!isdigit(c)) c=getchar();
  14. while(isdigit(c)) { x=x*+c-''; c=getchar(); }
  15. }
  16. void add(int u,int v)
  17. {
  18. to[++tot]=v; nxt[tot]=front[u]; front[u]=tot;
  19. to[++tot]=u; nxt[tot]=front[v]; front[v]=tot;
  20. }
  21. bool dfs(int x,int y,int z)
  22. {
  23. int sum=;
  24. for(int i=front[x];i;i=nxt[i])
  25. if(to[i]!=y) { if(!dfs(to[i],x,z)) return false; }
  26. for(int i=front[x];i;i=nxt[i])
  27. if(to[i]!=y) tmp[++sum]=dp[to[i]]+;
  28. sort(tmp+,tmp+sum+);
  29. for(sum;tmp[sum]+tmp[sum-]>z;sum--,cnt++);
  30. dp[x]=tmp[sum];
  31. if(cnt>p) return false;
  32. return true;
  33. }
  34. bool check(int mid)
  35. {
  36. memset(dp,,sizeof(dp));
  37. cnt=;
  38. return dfs(,,mid);
  39. }
  40. int main()
  41. {
  42. /* int size = 256 << 15;
  43. char *pp = (char*) malloc(size) + size;
  44. __asm__ ("movl %0, %%esp\n" :: "r"(pp));
  45. freopen("longnosee.in","r",stdin);
  46. freopen("longnosee.out","w",stdout); */
  47. int n;
  48. read(n), read(p);
  49. int u,v;
  50. for(int i=;i<n;i++)
  51. {
  52. read(u),read(v);
  53. add(u,v);
  54. }
  55. int l=,r=n,mid,ans;
  56. while(l<=r)
  57. {
  58. mid=l+r>>;
  59. if(check(mid)) ans=mid,r=mid-;
  60. else l=mid+;
  61. }
  62. printf("%d",ans);
  63. }

T3

大爆搜,粘std啦

  1. #include <cstdio>
  2. #include <iostream>
  3. #define rg register
  4. #define Max 22
  5. inline void read (int &now)
  6. {
  7. rg char c = getchar ();
  8. for (now = ; !isdigit (c); c = getchar ());
  9. for (; isdigit (c); now = now * + c - '', c = getchar ());
  10. }
  11. int _x[] = { , -, , , , }, _y[] = { , , , -, , }, _z[] = { , , , , , - };
  12. int N, M, Z, P, Sx, Sy, Sz, St, Tt,Tx, Ty, Tz, Answer; bool is[Max][Max][Max], dot[Max][Max][Max];
  13. 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]; }
  14. inline int abs (int a) { return a < ? -a : a; }
  15. void Dfs (int x, int y, int z, int t, int s)
  16. {
  17. int r = abs (x - Tx) + abs (y - Ty) + abs (z - Tz);
  18. if (s + (r >> ) >= Answer) return ;
  19. if (x == Tx && y == Ty && z == Tz) { if (t == Tt) Answer = s; return ; }
  20. rg int i, a, b, c;
  21. if (Can (x + _x[t], y + _y[t], z + _z[t]) && Can (x + _x[t] * , y + _y[t] * , z + _z[t] * ))
  22. {
  23. is[x + _x[t]][y + _y[t]][z + _z[t]] = true;
  24. is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = true;
  25. for (i = ; i < ; ++ i)
  26. if ((i >> ) != (t >> ) && Can (a + _x[i], b + _y[i], c + _z[i]) && Can (a + _x[i] * , b + _y[i] * , c + _z[i] * ))
  27. {
  28. is[a + _x[i]][b + _y[i]][c + _z[i]] = true;
  29. is[a + _x[i] * ][b + _y[i] * ][c + _z[i] * ] = true;
  30. Dfs (a + _x[i] * , b + _y[i] * , c + _z[i] * , i, s + );
  31. is[a + _x[i]][b + _y[i]][c + _z[i]] = false;
  32. is[a + _x[i] * ][b + _y[i] * ][c + _z[i] * ] = false;
  33. }
  34. if (Can (x + _x[t] * , y + _y[t] * , z + _z[t] * ))
  35. {
  36. is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = true;
  37. for (i = ; i < ; ++ i)
  38. if ((i >> ) != (t >> ) && Can (a + _x[i], b + _y[i], c + _z[i]))
  39. {
  40. is[a + _x[i]][b + _y[i]][c + _z[i]] = true;
  41. Dfs (a + _x[i], b + _y[i], c + _z[i], i, s + );
  42. is[a + _x[i]][b + _y[i]][c + _z[i]] = false;
  43. }
  44. is[a = (x + _x[t] * )][b = (y + _y[t] * )][c = (z + _z[t] * )] = false;
  45. }
  46. is[x + _x[t]][y + _y[t]][z + _z[t]] = false;
  47. is[x + _x[t] * ][y + _y[t] * ][z + _z[t] * ] = false;
  48. }
  49. }
  50. int Main ()
  51. {
  52. freopen ("blessyou.in", "r", stdin); freopen ("blessyou.out", "w", stdout);
  53. read (N), read (M), read (Z), read (P); rg int i, j; int x, y, z; rg char c;
  54. if (N <= && M <= && Z <= ) return printf ("Dream Battle"), ;
  55. read (Sx), read (Sy), read (Sz);
  56. for (c = getchar (); c != 'x' && c != 'y' && c != 'z'; c = getchar ());
  57. St = (c - 'x') << ;
  58. if (c == 'x') St += (Sx == N); else if (c == 'y') St += (Sy == M);
  59. else if (c == 'z') St += (Sz == Z);
  60. Sx -= _x[St], Sy -= _y[St], Sz -= _z[St];
  61. read (Tx), read (Ty), read (Tz);
  62. for (c = getchar (); c != 'x' && c != 'y' && c != 'z'; c = getchar ());
  63. Tt = (c - 'x') << ;
  64. if (c == 'x') Tt += (Tx == ); else if (c == 'y') Tt += (Ty == );
  65. else if (c == 'z') Tt += (Tz == );
  66. for (i = ; i <= P; ++ i) read (x), read (y), read (z), dot[x][y][z] = true;
  67. Answer = ; Dfs (Sx, Sy, Sz, St, );
  68. if (Answer == ) printf ("Dream Battle"); else printf ("%d", Answer);
  69. return ;
  70. }
  71. int ZlycerQan = Main (); int main (int argc, char *argv[]) { return ; }

NOIP模拟赛11的更多相关文章

  1. 11/1 NOIP 模拟赛

    11.1 NOIP 模拟赛 期望得分:50:实际得分:50: 思路:暴力枚举 + 快速幂 #include <algorithm> #include <cstring> #in ...

  2. NOIP模拟赛-2018.11.7

    NOIP模拟赛 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 如果用命令行编译程序可以发现没加头文件之类的错误. 编译之前另存一份,听说如果敲 ...

  3. NOIP模拟赛-2018.11.6

    NOIP模拟赛 今天想着反正高一高二都要考试,那么干脆跟着高二考吧,因为高二的比赛更有技术含量(我自己带的键盘放在这里). 今天考了一套英文题?发现阅读理解还是有一些困难的. T1:有$n$个点,$m ...

  4. NOIP模拟赛-2018.11.5

    NOIP模拟赛 好像最近每天都会有模拟赛了.今天从高二逃考试跑到高一机房,然而高一也要考试,这回好像没有拒绝的理由了. 今天的模拟赛好像很有技术含量的感觉. T1:xgy断句. 好诡异的题目,首先给出 ...

  5. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  6. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  7. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  8. 10.17 NOIP模拟赛

    目录 2018.10.17 NOIP模拟赛 A 咒语curse B 神光light(二分 DP) C 迷宫maze(次短路) 考试代码 B 2018.10.17 NOIP模拟赛 时间:1h15min( ...

  9. NOI.AC NOIP模拟赛 第三场 补记

    NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...

随机推荐

  1. 解决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 ...

  2. ubuntu下配置ss并设置PAC模式

    一.安装ss 1. sudo apt-get update(更新源) 2. sudo apt-get install python-pip(安装pip) 3. sudo pip install sha ...

  3. BETA阶段第一天

    1.提供当天站立式会议照片一张 2.每个人的工作 今天完成工作 林一心 服务器调试 张杭镖 数据库调整 赵意 前端设计 江鹭涛 前端设计 3.发布项目燃尽图 4.每日每人总结 林一心:服务器端的配置不 ...

  4. Windows Forms编程实战学习:第一章 初识Windows Forms

    初识Windows Forms 1,用C#编程 using System.Windows.Forms;   [assembly: System.Reflection.AssemblyVersion(& ...

  5. 敏捷冲刺DAY8

    一. 每日会议 1. 照片 2. 昨日完成工作 第一次阶段测试. 3. 今日完成工作 对前七次敏捷冲刺的工作进行完善. 4. 工作中遇到的困难 浏览器兼容性问题.页面响应性能问题.内存溢出问题-- 二 ...

  6. 微信小程序组件 自定义单选

    <view class='userperson'> <view class='f30 flexca'>请选择您的注册身份</view> <view class ...

  7. vue-cli3使用cdn方式引入moment.js

    1. index.html引入: <script src="https://cdn.bootcss.com/moment.js/2.20.1/moment.min.js"&g ...

  8. PHP面向对象之重载

    重载技术overloading 重载的基本概念 重载在“通常面向对象语言”中的含义: 是指,在一个类(对象)中,有多个名字相同但形参不同的方法的现象: 类似这样: class   C{ functio ...

  9. Oracle schema 的含义

    方案(Schema)为数据库对象的集合,为了区分各个集合,我们需要给这个集合起个名字,这些名字就是我们在企业管理器的方案下看到的许多类似用户名的节点,这些类似用户名的节点其实就是一个schema,sc ...

  10. 【Python】Python流程控制

    1)if条件测试 Python的比较操作 所有的Python对象都支持比较操作 测试操作符('=='操作符测试值的相等性: 'is'表达式测试对象的一致性) Python中不同类型的比较方法 数字:通 ...