Noip 1998 洛谷P1011 车站 - 模拟
2017-10-31 17:12
267 查看
挺好玩的一道题。。。需要知道第二站到底上了多少人,可以枚举这个人数,然后模拟过去,看最后一站下车的人数是否等于m,求出这个人数后再模拟一次就好了
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> using namespace std; #define debug(x) cerr << #x << "=" << x << endl; const int MAXN = 2000 + 10; int stat[MAXN], train[MAXN], a,n,m,x; void init() { memset(stat, 0, sizeof(stat)); memset(train, 0, sizeof(train)); } int guess() { int tempa; bool flg = true; for(int i=1; i<=m; i++) { init(); stat[1] = a; stat[2] = i; train[1] = train[2] = a; for(int o=3; o<n; o++) { stat[o] = stat[o-1] + stat[o-2]; train[o] = stat[o] + train[o-1]; train[o] -= stat[o-1]; } if(train[n-1] == m) { flg = true; tempa = i; 4000 break; } } if(flg) return tempa; } int main() { cin >> a >> n >> m >> x; int ta = guess(); init(); stat[1] = a; stat[2] = ta; train[1] = a; train[2] = a; for(int i=3; i<=n; i++) { stat[i] = stat[i-1] + stat[i-2]; train[i] = stat[i] + train[i-1]; train[i] -= stat[i-1]; } cout << train[x]; return 0; }
相关文章推荐
- [NOIP1998] 提高组 洛谷P1011 车站
- 洛谷 P1983 [NOIP2013普及组 T4] 车站分级
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- [NOIP1998] 提高组 洛谷P1012 拼数
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- 洛谷 P1948 [USACO08JAN]电话线Telephone Lines【NOIP模拟笨笨的电话线】
- 洛谷P1011 车站
- 洛谷 P1011 车站
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- noip 1998 洛谷P1013 进制位
- 刷题报告003 洛谷P1011 车站
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- NOIP1998提高组 车站
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- 【递推】洛谷 P1011 车站
- jozj. 3927. 【NOIP2014模拟11.6】可见点数 洛谷 P2158 [SDOI2008]仪仗队
- |洛谷|NOIP2014|模拟|P1328 生活大爆炸版石头剪刀布
- 洛谷1071 潜伏者 NOIP2009 字符串模拟
- [NOIP2017模拟][洛谷3939]数颜色