TG2016D1T1&D2T1讲解
来源:互联网 发布:php判断淘宝店铺链接 编辑:程序博客网 时间:2024/05/22 13:27
D1T1玩具谜题
纯模拟过。
#include<iostream>#include<string.h>#include<cstdio>#include<stdlib.h>#include<math.h>#include<algorithm>#define fr(i,a,b) for(int i=a,_end_=b;i<=_end_;i++)#define fd(i,a,b) for(int i=a,_end_=b;i>=_end_;i--)using namespace std;int a,b,n,m,x,g[100010];char name[100010][20];int main(){ freopen("toy.in","r",stdin); freopen("toy.out","w",stdout); scanf("%d%d",&n,&m); fr(i,1,n) scanf("%d%s",&g[i],&name[i]);//读入每个人的信息 x=1;//当前的小人 fr(i,1,m) { scanf("%d%d",&a,&b); a^=g[x];//面朝外与面朝内的方向相反 a=a*2-1;//0->0*2-1=-1 1->1*2-1=1 x+=a*b;//直接乘 while(x<1)x+=n;//处理超界 while(x>n)x-=n; } printf("%s\n",name[x]); return 0;}
D2T1组合数问题
纯DP,DP 2次
一次求Cij,一次求答案。
(注意mod)
即每次看最后元素,选与不选的情况。
即计算(x,y)前共有多少个0。
#include<iostream>#include<cstdio>#include<stdlib.h>#include<string.h>#include<math.h>#include<algorithm>#define fr(i,a,b) for(int i=a,_end_=b;i<=_end_;i++)#define fd(i,a,b) for(int i=a,_end_=b;i>=_end_;i--)using namespace std;int t,k,f[2010][2010],c[2010][2010],n[10010],m[10010],maxn,maxm;int main(){ freopen("problem.in","r",stdin); freopen("problem.out","w",stdout); scanf("%d%d",&t,&k); fr(i,1,t) { scanf("%d%d",&n[i],&m[i]); maxn=max(maxn,n[i]); maxm=max(maxm,m[i]); } memset(c,-1,sizeof(c)); fr(i,0,maxn) c[i][0]=1; fr(i,0,min(maxn,maxm)) c[i][i]=1; fr(i,2,maxn) fr(j,1,min(i-1,maxm)) c[i][j]=(c[i-1][j-1]+c[i-1][j])%k; fr(i,1,maxn) fr(j,1,maxm) f[i][j]=f[i-1][j]+f[i][j-1]-f[i-1][j-1]+(!c[i][j]); fr(i,1,t) printf("%d\n",f[n[i]][m[i]]); return 0;}
0 0
- TG2016D1T1&D2T1讲解
- NOIP2012 D2T1
- NOIP2015 TG D2T1 stone
- 【GDKOI2016】D2T1染色大战
- NOIP2013 D2T1 积木大赛
- Noip2015 D2T1 跳石头
- NOIP 2017 D2T1 奶酪
- NOIP2017 D2T1 奶酪
- HNOI 2016 D2T1 序列 (sequence)
- NOIP 2015 D2T1 跳石头
- NOIP 2013 D2T1 积木大赛
- Noip 2015 D2T1 跳石头
- [sdoi2017][bzoj4819] D2T1 新生舞会
- UOJ #5 [NOI2014 D2T1] 动物园
- NOIP2017提高组D2T1[奶酪]
- POJ 3258 (NOIP2015 D2T1跳石头)
- [BZOJ4554][JZOJ4612] 【TJOI&HEOI2016】D2T1 游戏
- 洛谷 P1082 [NOIP2012 D2T1] 同余方程
- 《Reverse Engineering for Beginners》 - 第1章 代码模式 - 笔记(1.1-1.3)
- redis之list
- 关于中值滤波算法,以及C语言实现
- html5实现摇一摇功能
- 分享个JAVA学习路线
- TG2016D1T1&D2T1讲解
- 《Reverse Engineering for Beginners》 - 第1章 代码模式 - 笔记(1.4)
- 代码中看到后收集的一些shader学习笔记
- 正则表达式
- centos7-x86-64卸载自带jdk并安装1.8jdk
- Java Object Serialization Specification
- Spring Bean装配之Resource
- 程序员这样对待简历,你期望面试官怎么对待你?
- Lwip----ECHO Protocol