摘要: 题目:http://codeforces.com/contest/246/problem/A题目给出错误的冒泡排序法,求反例。思路:...既然是错误的,任意输出一个递减的数列#include <iostream>using namespace std;int main(){ int n; cin>>n; if(n<=2) cout<<"-1"; else { for(int i=0;i<n-2;i++) { cout<<n-i<<" "; } cout<<"2 阅读全文
posted @ 2013-01-19 22:32 Daniel Qiu 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 题目:http://codeforces.com/contest/248/problem/An个橱柜 每个橱柜左右两扇门 用0、1纪录关和开的状态,问要使所有左门状态相同,右门状态相同,最少需要对门做几次操作思路:贪心法 分别统计左右门,输出关闭的状态和打开的状态中的较小值。#include <iostream>using namespace std;int l,r;int lopen=0,lclose=0,ropen=0,rclose=0;int main(){ int n; cin>>n; for(int i=0;i<n;i++) { cin >> 阅读全文
posted @ 2013-01-19 22:00 Daniel Qiu 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 题目:http://codeforces.com/contest/250/problem/A将数列分割城若干个数列,每个子数列的负元素不得超过两个,使子数列个数最少,输出子数列个数,和每个子数列元素个数。思路:贪心法#include <iostream>using namespace std;int a[100];int b[100];int bi=0;int bn=1;int main(){ int n; cin>>n; for(int i=0;i<n;i++) { cin >> a[i]; } int neg=0; for(int i=0;i< 阅读全文
posted @ 2013-01-19 21:43 Daniel Qiu 阅读(145) 评论(0) 推荐(0) 编辑