2012年1月14日
摘要: 这题乍一看,没有什么思路。不过画了下图,就大概猜到了。当输入为1行或1列时,那么最大值肯定为max(n,m).当输入为2行或2列时,那么最大值也可分析的出来:max(n,m)/4)*4+2(max(n,m)%4 == 1),max(n,m)/4)*4(max(n,m)%4 == 0),max(n,m)/4)*4+4(其他)这三种情况.当输入为其他时,分析可知如果n*m%2 == 0,则为n*m/2.反之则为n*m/2+1.View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 阅读全文
posted @ 2012-01-14 15:32 Dev-T 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 这题只要看下题目的数据量就知道肿么做了。1<=n<=10^9。直接暴力枚举其因子,时间复杂度为O(sqrt(n)*(sqrt(sqrt(n))));想想应该能过,还有一点就是最大最小值的求法:最大值:把3个因子中的最大值加1,其余加2.最小值:把3个因子中的最小值加1,其余加2.介个很容易证明。。。。。。还有一点要用__int64View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 inline __int64 max(__int64 a, __int64 b 阅读全文
posted @ 2012-01-14 15:26 Dev-T 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 唉~~~格式处理题,水题啊。。。。。。细节还是很重要的View Code 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 5 int main() 6 { 7 char data[110]; 8 char newdata[200]; 9 for (int i(0); i<110; ++i)data[i] = '0';10 cin>>data;11 newdata[0] = '$';12 bool flag = false;13 int c 阅读全文
posted @ 2012-01-14 15:20 Dev-T 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 呃。。。暴力水题,不解释。View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 bool vis[10]; 6 bool law(int x) 7 { 8 return x<=9 && x>=1 && !vis[x]; 9 }10 11 12 int main()13 {14 for (int i(1); i<=9; ++i)vis[i] = false;15 int c1,c2,r1,r2,d1,d2;16 scanf( 阅读全文
posted @ 2012-01-14 15:17 Dev-T 阅读(178) 评论(0) 推荐(0) 编辑