2016年2月18日

摘要: 分析: 此题没想出更好的方法,用模拟解决。(只学习语言的同学做这样的题目有一定难度) 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 int w[11000], b[11000]; 5 int main(){ 6 i 阅读全文
posted @ 2016-02-18 21:02 noip之路 阅读(895) 评论(0) 推荐(0) 编辑
 
摘要: 分析: 需要使用二维数组存储地毯的编号,后面的地毯编号覆盖前面的。 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[11000][11000]={0}; int main(){ int 阅读全文
posted @ 2016-02-18 18:42 noip之路 阅读(309) 评论(0) 推荐(0) 编辑
 
摘要: 分析: 方法1:先使用数组a记录,然后使用双重循环逐个比较,把不重复的数值记录到b中。时间复杂度O(n^2)(n=10000)超时; 方法2:先使用数组a记录,然后对数组进行排序。再扫描一遍a,将不重复的数值记录在b数组. STL里面有个sort函数,sort 可以对给定区间所有元素进行排序,默认的 阅读全文
posted @ 2016-02-18 18:04 noip之路 阅读(2256) 评论(2) 推荐(0) 编辑
 
摘要: 使用数组 #include<cstdio> #include<cstring> int a[1100]={0}; int main(){ int x,y,n,maxn=-1,num=1; scanf("%d",&n); scanf("%d",&a[0]); for(int i=1;i<=n-1;i+ 阅读全文
posted @ 2016-02-18 17:09 noip之路 阅读(178) 评论(0) 推荐(0) 编辑
 
摘要: 题目没有说明是什么字符,但ascii码是0~255,可以直接定义一个数组a[1000]. 如何记录字符连续出现的次数? 逐字符扫描,定义一个变量记录,初值为1 #include<cstdio> #include<cstring> char s[1100]; int a[1100]={0}; int 阅读全文
posted @ 2016-02-18 17:06 noip之路 阅读(773) 评论(0) 推荐(0) 编辑