2014
02-27

# Number game

One day, QQ is playing a number game. He first sorts the N numbers 1, 2, 3…n, but this is too easy. So long1 wants to challenge QQ’s skill, he let the number sequence becomes wavy. For example, a1<a2>a3<a4>a5… or a1>a2<a3>a4<a5….
Now long1 sorts these wavy sequences by lexicographic order, and he wants to know what the M-th sequence is when you have N numbers.
As an Acmer, long1 thinks you can solve it and gives him the answer.

There are many test cases:
For every case:

First line is the number of case
The next case lines:
Every line contains two numbers N, and M.(1<=N<=20,M is not larger than the number of wavy sequences)

There are many test cases:
For every case:

First line is the number of case
The next case lines:
Every line contains two numbers N, and M.(1<=N<=20,M is not larger than the number of wavy sequences)

2
2 1
3 3 

1 2
2 3 1
Hint
Hint: You can assume that the number of total wavy sequences will not beyond INT64.


/*

每一天都只能每一种鱼，并且买了这种鱼后，在以后每周的该天都得买那种鱼。
另外如果某一天没买鱼的话，就不能在以后买鱼了（已被饿死。。。）。现在
给出n天每一种鱼的价格，并且给出你拥有的价钱，问你什么时候不能再买鱼了

map[i,j]表示从第一天开始买了j种鱼到i天时所用的总价钱。然后从后面开始枚举
答案，枚举一周内每天所使用的价钱总和若不大于你拥有的金钱时就输出答案

*/
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int X = 10002;
const int maxn = 51;

int map[X][maxn];
int n,m,budge;

int main()
{
freopen("sum.in","r",stdin);
while(cin>>n>>m>>budge)
{
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
scanf("%d",&map[i][j]);
for(int i=7;i<n;i++)
for(int j=0;j<m;j++)
map[i][j] += map[i-7][j];
int ans;
int sum = 0;
for(ans=n;ans>0;ans--)
{
sum = 0;
for(int i=ans-1;i>=0&&i>=ans-7;i--)
{
int MIN = 1e9;
for(int j=0;j<m;j++)
MIN = min(MIN,map[i][j]);
if(MIN>budge)
{
sum = 1e9;
break;
}
sum += MIN;
if(sum>budge)
break;
}
if(sum<=budge)
break;
}
cout<<ans<<endl;
}
return 0;
}

1. 怎么说，也好也不好。好处是可以缓和社会矛盾，对民意也更重视，政党的轮换也有利于保持清廉。不好的地方就是政党可能会责任感不足，只重视民意，不办实事，办事拖塌，难以进行真正的改革，政策的延续性不好，对发展中国家来说就是制约发展的速度，导至人们一次又一次的上街

2. 在方法1里面：

//遍历所有的边，计算入度
for(int i=0; i<V; i++)
{
degree = 0;