摘要:
http://poj.org/problem?id=3184题意:移动奶牛的位置,使相邻两头奶牛的距离满足D或D+1,要注意第一头奶牛在第一个位置,最后一头在最后一个位置,求奶牛的移动步数;思路:滚动数组来记录从第一头奶牛开始所在位置的最小移动步数;代码:View Code #include <cstdio>#include <algorithm>#include <iostream>#include <cstring>using namespace std;#define max 9999999int a[10010] = {0};int s[ 阅读全文