摘要: Moving Tables/*解题思路:这道题最少花多少时间,实际上我们只要考虑哪一段重合度最高, 重合度最高的地方,也就是我们至少要移动的次数了。 因为有400间房间,1-2对应一段走廊,3-4对应一段走廊, 如此我们可以把走廊分成200段,标记为a[1]-a[200], 之后我们根据输进的房间序号,就可以算出要用到哪几段的走廊, 之后给对应的a[n]值加1就好,最后求出a[n]最大值就是移动的次数了。 */ #include #include #include using namespace std; int main() { int T; int pair; int a[201];... 阅读全文
posted @ 2013-04-20 21:10 VeryBigMan 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Elevator#include using namespace std; int main() { int n,temp,last=0,sum,N; while(cin>>n,n!=0) { sum=0; last=0; N=n; while(n--) { cin>>temp; if(temp>last) { sum+=(temp-last)*6; last=temp; } else { sum+=(last-temp)*4; last=temp; } } cout using na... 阅读全文
posted @ 2013-04-20 21:07 VeryBigMan 阅读(84) 评论(0) 推荐(0) 编辑
摘要: A+B for Input-Output Practice (I)#include using namespace std; int main() { int a,b; while(cin>>a>>b) cout using namespace std; int main() { int T; int a,b; cin>>T; while(T--) { cin>>a>>b; cout using namespace std; int main() { int a,b; while(cin>>a>>b,a!=0| 阅读全文
posted @ 2013-04-20 21:03 VeryBigMan 阅读(111) 评论(0) 推荐(0) 编辑