摘要: 刚开始用公式暴力做了一下,RE了,不得不转战其他方法,看着公式貌似很有规律的样子就试着找了一下,结果就这么A了,嘿嘿~代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int f[4][1000002]; 5 int main() 6 { 7 int i,j; 8 int m,n; 9 for(i=0;i<=1000000;i++)10 f[1][i]=i+2;11 for(i=0;i<=1000000;i++)12 {13 f[2][i]=i+... 阅读全文
posted @ 2011-12-11 20:56 Misty_1 阅读(155) 评论(0) 推荐(0)
摘要: 刚开始没看懂题,看了题给的例子,说是101可能有91或100的来,以为是让求只有只有一个数得来的那些数呢,暴力做了一下,WA了。然后搜了一下,发现是让求不是任何数的和的那些数,无语~代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int h[1000002]; 5 int main() 6 { 7 int i,j,s; 8 memset(h,0,sizeof(h)); 9 for(i=1;i<=1000000;i++)10 {11 j=i;s=i;12 ... 阅读全文
posted @ 2011-12-11 20:06 Misty_1 阅读(172) 评论(0) 推荐(0)
摘要: 其实这题很水~但是通过做这题我终于知道了cin的输入有多慢了,以前做题总感觉自己很别人的思路一样怎么就慢了那么长时间呢,现在知道了,有一部分原因是有cin,cout输入输出的原因。这题用cin输入会超时,有scanf就ok了。其实这题就是一个递推公式,dp[i][j]=max(dp[i-1][j],max(dp[i-1][j-1],dp[i][j-1]));代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int a[1002][1002]; 5 int max(int x 阅读全文
posted @ 2011-12-10 14:19 Misty_1 阅读(217) 评论(0) 推荐(0)
摘要: 读完题就知道是一道模拟题,但遗憾的是我的模拟题做得并不好,可能是自己的代码能力还不够好吧~~放了一段时间,今天中下决心做了。刚开始觉得用while一直搜到一个上升或下降序列的最后,但对于像4 4 4 4 这样的序列就不好判断属于上升还是下降序列了,后来看了一下解题报告,明白了~其实不用管一个上升或下降序列到底用多长,只判断这个数与他前面的数构成上升还是下降就可以了,中间加些判断的标量~代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream 阅读全文
posted @ 2011-12-08 16:14 Misty_1 阅读(273) 评论(0) 推荐(0)
摘要: 水题~,就是给你两个数,先把这两个数翻转,然后将这两个数相加在翻转输出,注意不要输出前导零,但中间的零要输出。代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream> 5 using namespace std; 6 int reverse(int x) 7 { 8 int s=0; 9 while(x)10 {11 s=s*10+x%10;12 x=x/10;13 }14 return s;15 }16 i... 阅读全文
posted @ 2011-12-06 09:12 Misty_1 阅读(221) 评论(0) 推荐(0)
摘要: 这题的意思就是求前后数差值的绝对值的个数,而且不能重复,本来想用hash的,但是题目没给出数的范围不好用,上网上找了下,看到他们都用bitset做的,就顺带学了一下bitset的用法,收获很大。代码: 1 #include<stdio.h> 2 #include<iostream> 3 #include<bitset> 4 #include<math.h> 5 using namespace std; 6 int main() 7 { 8 bitset<4000>b; 9 int n,m;10 while(scanf("%d 阅读全文
posted @ 2011-12-04 18:42 Misty_1 阅读(205) 评论(0) 推荐(0)
摘要: 水题,刚开始没读懂题意,后来明白怎么回事了,不得不说真的很水~其实题目就是给你一个01序列让你计算将该序列变成01交替的序列最少需要几步~代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<iostream> 4 using namespace std; 5 int main() 6 { 7 int n,x,s1,s2,m1,m2; 8 while(scanf("%d",&n)!=EOF) 9 {10 s1=s2=m1=m2=0;11 for(int i=1;i<= 阅读全文
posted @ 2011-12-04 16:21 Misty_1 阅读(176) 评论(0) 推荐(0)
摘要: 一道简单的大整数加法题,让我做了整整一晚上,无语~~太马虎了,题目中说每个数长度小于等于100,但和不一定小于100啊,唉~·我就在栽在了这上面~~代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream> 5 using namespace std; 6 int main() 7 { 8 int t,i,len,k,a[103],b[103],l,tem; 9 char str[103];10 while(scanf(&q 阅读全文
posted @ 2011-12-02 21:08 Misty_1 阅读(259) 评论(0) 推荐(0)
摘要: 这道题的意思是说,输入一数列,如果前面是‘P’,则就该数列各个数的逆序对输出,输入‘I’则将原来的数列输出。第一种情况比较好处理,第二种有点小麻烦。第二种情况要符合下面两个要求:1、先找到a[i]中最小的放在开头;2、i前面要有a[i]个比i大的数;代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream> 5 using namespace std; 6 int a[102],b[102]; 7 int jude(int x,int 阅读全文
posted @ 2011-12-02 19:28 Misty_1 阅读(286) 评论(0) 推荐(0)
摘要: 我认为这题更像一道数学题,找规律的,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ...就是要找到这些数之间的规律,a[i]=max(a[s1]*2,max(a[s2]*3,max(a[s3]*5,a[s4]*7)));就是输出格式有点麻烦。代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<iostream> 5 using namespace st 阅读全文
posted @ 2011-11-30 21:40 Misty_1 阅读(162) 评论(0) 推荐(0)