A

无trick水题。。。

  1. /*
  2. * Author: Plumrain
  3. * Created Time: 2013-12-24 22:26
  4. * File Name: B.cpp
  5. */
  6. #include <iostream>
  7. #include <cstdio>
  8. #include <cstring>
  9. #include <string>
  10. #include <cmath>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <cstdlib>
  14. #include <sstream>
  15. #include <fstream>
  16. #include <list>
  17. #include <deque>
  18. #include <queue>
  19. #include <stack>
  20. #include <map>
  21. #include <set>
  22. #include <bitset>
  23. #include <cctype>
  24. #include <ctime>
  25. #include <utility>
  26.  
  27. using namespace std;
  28.  
  29. #define clr0(x) memset(x, 0, sizeof(x))
  30. #define clr1(x) memset(x, -1, sizeof(x))
  31. #define pb push_back
  32. #define sz(v) ((int)(v).size())
  33. #define all(t) t.begin(),t.end()
  34. #define INF 999999999999999999
  35. #define zero(x) (((x)>0?(x):-(x))<eps)
  36. #define out(x) cout<<#x<<":"<<(x)<<endl
  37. #define tst(a) cout<<a<<" "
  38. #define tst1(a) cout<<#a<<endl
  39. #define CINBEQUICKER std::ios::sync_with_stdio(false)
  40.  
  41. const double eps = 1e-;
  42. const double PI = atan(1.0)*;
  43. const int inf = / ;
  44.  
  45. typedef vector<int> vi;
  46. typedef vector<string> vs;
  47. typedef vector<double> vd;
  48. typedef pair<int, int> pii;
  49. typedef long long int64;
  50.  
  51. inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;}
  52.  
  53. int ru[], chu[];
  54.  
  55. int main()
  56. {
  57. // freopen("a.in","r",stdin);
  58. // freopen("a.out","w",stdout);
  59. // std::ios::sync_with_stdio(false);
  60. int n, m;
  61. while (scanf ("%d%d", &n , &m) != EOF){
  62. int t1, t2, w;
  63. clr0 (chu); clr0 (ru);
  64. for (int i = ; i < m; ++ i){
  65. scanf ("%d%d%d", &t1, &t2, &w);
  66. chu[--t1] += w;
  67. ru[--t2] += w;
  68. }
  69. int ans = ;
  70. for (int i = ; i < n; ++ i)
  71. ans += abs(chu[i] - ru[i]);
  72. printf ("%d\n", ans / );
  73. }
  74. return ;
  75. }

B

YY题。。。结论直接看代码就好了。。。比赛的时候YY出了结论算样例算错了,然后就去想别的方法了。。。。。。

  1. /*
  2. * Author: Plumrain
  3. * Created Time: 2013-12-24 22:26
  4. * File Name: B.cpp
  5. */
  6. #include <iostream>
  7. #include <cstdio>
  8. #include <cstring>
  9. #include <string>
  10. #include <cmath>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <cstdlib>
  14. #include <sstream>
  15. #include <fstream>
  16. #include <list>
  17. #include <deque>
  18. #include <queue>
  19. #include <stack>
  20. #include <map>
  21. #include <set>
  22. #include <bitset>
  23. #include <cctype>
  24. #include <ctime>
  25. #include <utility>
  26.  
  27. using namespace std;
  28.  
  29. #define clr0(x) memset(x, 0, sizeof(x))
  30. #define clr1(x) memset(x, -1, sizeof(x))
  31. #define pb push_back
  32. #define sz(v) ((int)(v).size())
  33. #define all(t) t.begin(),t.end()
  34. #define INF 999999999999999999
  35. #define zero(x) (((x)>0?(x):-(x))<eps)
  36. #define out(x) cout<<#x<<":"<<(x)<<endl
  37. #define tst(a) cout<<a<<" "
  38. #define tst1(a) cout<<#a<<endl
  39. #define CINBEQUICKER std::ios::sync_with_stdio(false)
  40.  
  41. const double eps = 1e-;
  42. const double PI = atan(1.0)*;
  43. const int inf = / ;
  44.  
  45. typedef vector<int> vi;
  46. typedef vector<string> vs;
  47. typedef vector<double> vd;
  48. typedef pair<int, int> pii;
  49. typedef long long int64;
  50.  
  51. inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;}
  52.  
  53. int ru[], chu[];
  54.  
  55. int main()
  56. {
  57. // freopen("a.in","r",stdin);
  58. // freopen("a.out","w",stdout);
  59. // std::ios::sync_with_stdio(false);
  60. int n, m;
  61. while (scanf ("%d%d", &n , &m) != EOF){
  62. int t1, t2, w;
  63. clr0 (chu); clr0 (ru);
  64. for (int i = ; i < m; ++ i){
  65. scanf ("%d%d%d", &t1, &t2, &w);
  66. chu[--t1] += w;
  67. ru[--t2] += w;
  68. }
  69. int ans = ;
  70. for (int i = ; i < n; ++ i)
  71. ans += abs(chu[i] - ru[i]);
  72. printf ("%d\n", ans / );
  73. }
  74. return ;
  75. }

C

题意:给一个很大的数m,这个数的各个位上的数字中一定含有至少1个1,6,8,9。你可以重新组织所有数字的顺序,使得重新排列之后的数能被7整除。10^4 <= m <= 10^(10^6)。

   注意,排列之后的数不能含有前导0。

解法:把1,6,8,9四个数字放在最后面,根据前面的数*10000除以7的余数,来决定1,6,8,9四个数字的排列顺序即可。至于有没有前导0,特殊处理一下即可。

tag:math, think

  1. /*
  2. * Author: Plumrain
  3. * Created Time: 2013-12-25 14:09
  4. * File Name: C.cpp
  5. */
  6. #include <iostream>
  7. #include <cstdio>
  8. #include <cstring>
  9. #include <string>
  10. #include <cmath>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <cstdlib>
  14. #include <sstream>
  15. #include <fstream>
  16. #include <list>
  17. #include <deque>
  18. #include <queue>
  19. #include <stack>
  20. #include <map>
  21. #include <set>
  22. #include <bitset>
  23. #include <cctype>
  24. #include <ctime>
  25. #include <utility>
  26.  
  27. using namespace std;
  28.  
  29. #define clr0(x) memset(x, 0, sizeof(x))
  30. #define clr1(x) memset(x, -1, sizeof(x))
  31. #define pb push_back
  32. #define sz(v) ((int)(v).size())
  33. #define all(t) t.begin(),t.end()
  34. #define INF 999999999999999999
  35. #define zero(x) (((x)>0?(x):-(x))<eps)
  36. #define out(x) cout<<#x<<":"<<(x)<<endl
  37. #define tst(a) cout<<a<<" "
  38. #define tst1(a) cout<<#a<<endl
  39. #define CINBEQUICKER std::ios::sync_with_stdio(false)
  40.  
  41. const double eps = 1e-;
  42. const double PI = atan(1.0)*;
  43. const int inf = / ;
  44.  
  45. typedef vector<int> vi;
  46. typedef vector<string> vs;
  47. typedef vector<double> vd;
  48. typedef pair<int, int> pii;
  49. typedef long long int64;
  50.  
  51. inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;}
  52.  
  53. bool del[];
  54. string temp = "";
  55. map<int, string> mp;
  56.  
  57. void gao(string s)
  58. {
  59. stringstream stm(s);
  60. int num; stm >> num;
  61. int yu = num % ;
  62. if (!mp.count(yu)) mp[yu] = s;
  63. }
  64.  
  65. int main()
  66. {
  67. // freopen("a.in","r",stdin);
  68. // freopen("a.out","w",stdout);
  69. // std::ios::sync_with_stdio(false);
  70. mp.clear();
  71. string tt = "";
  72. gao(tt);
  73. while (next_permutation(tt.begin(), tt.end())) gao(tt);
  74.  
  75. string s;
  76. while (cin >> s){
  77. clr0 (del);
  78. string ss; ss.clear();
  79. int n = sz(s), cnt = ;
  80. for (int i = ; i < n; ++ i){
  81. if (s[i] == ''){
  82. ++ cnt; continue;
  83. }
  84. bool ok = ;
  85. for (int j = ; j < ; ++ j) if (s[i] == temp[j] && !del[j]){
  86. del[j] = ; ok = ;
  87. }
  88. if (!ok) ss.pb (s[i]);
  89. }
  90.  
  91. int len = sz(ss);
  92. if (!len){
  93. ss = mp[];
  94. for (int i = ; i < cnt; ++ i) ss.pb ('');
  95. cout << ss << endl;
  96. continue;
  97. }
  98. for (int i = ; i < cnt; ++ i) ss.pb ('');
  99. len = sz(ss);
  100. int flag = ;
  101. for (int i = ; i < len; ++ i)
  102. flag = (flag* + ss[i] - '') % ;
  103. flag = flag * % ;
  104. ss += mp[( - flag) % ];
  105. cout << ss << endl;
  106. }
  107. return ;
  108. }

D

题意:有一个0,1矩阵(最大5000*5000),你可以无限次数地交换任意两行的位置。求交换之后,单个只含有1的矩形的面积最大,并返回这个面积值。

解法:枚举矩形的左下角是从哪一列开始,统计每一行从这一列开始连续的1有多少个记录在num数组里,然后从大到小遍历num数组,并更新面积值即可。

tag:dp, think, good

  1. /*
  2. * Author: Plumrain
  3. * Created Time: 2013-12-26 12:49
  4. * File Name: D.cpp
  5. */
  6. #include <iostream>
  7. #include <cstdio>
  8. #include <cstring>
  9. #include <string>
  10. #include <cmath>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <cstdlib>
  14. #include <sstream>
  15. #include <fstream>
  16. #include <list>
  17. #include <deque>
  18. #include <queue>
  19. #include <stack>
  20. #include <map>
  21. #include <set>
  22. #include <bitset>
  23. #include <cctype>
  24. #include <ctime>
  25. #include <utility>
  26.  
  27. using namespace std;
  28.  
  29. #define clr0(x) memset(x, 0, sizeof(x))
  30. #define clr1(x) memset(x, -1, sizeof(x))
  31. #define pb push_back
  32. #define sz(v) ((int)(v).size())
  33. #define all(t) t.begin(),t.end()
  34. #define INF 999999999999999999
  35. #define zero(x) (((x)>0?(x):-(x))<eps)
  36. #define out(x) cout<<#x<<":"<<(x)<<endl
  37. #define tst(a) cout<<a<<" "
  38. #define tst1(a) cout<<#a<<endl
  39. #define CINBEQUICKER std::ios::sync_with_stdio(false)
  40.  
  41. const double eps = 1e-;
  42. const double PI = atan(1.0)*;
  43. const int inf = / ;
  44.  
  45. typedef vector<int> vi;
  46. typedef vector<string> vs;
  47. typedef vector<double> vd;
  48. typedef pair<int, int> pii;
  49. typedef long long int64;
  50.  
  51. inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;}
  52.  
  53. int n, m;
  54. int p[][], num[];
  55. char v[][];
  56.  
  57. int main()
  58. {
  59. // freopen("a.in","r",stdin);
  60. //freopen("a.out","w",stdout);
  61. // std::ios::sync_with_stdio(false);
  62. while (scanf ("%d%d", &n, &m) != EOF){
  63. string s;
  64. for (int i = ; i < n; ++ i)
  65. scanf ("%s", v[i]);
  66. for (int i = ; i < n; ++ i){
  67. int tmp = m;
  68. for (int j = m-; j >= ; -- j){
  69. if (v[i][j] == '')
  70. tmp = j, p[i][j] = j;
  71. else
  72. p[i][j] = tmp;
  73. }
  74. }
  75. int ans = ;
  76. for (int i = ; i < m; ++ i){
  77. clr0 (num);
  78. for (int j = ; j < n; ++ j) num[p[j][i] - i] ++;
  79. int pos = ;
  80. while (pos && num[pos] == ) -- pos;
  81. int cnt = ;
  82. while (pos){
  83. if (num[pos]) cnt += num[pos];
  84. ans = max(cnt*pos, ans);
  85. -- pos;
  86. }
  87. }
  88. printf ("%d\n", ans);
  89. }
  90. return ;
  91. }

CodeForces 221(div 2)的更多相关文章

  1. Codeforces #344 Div.2

    Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...

  2. Codeforces #345 Div.1

    Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...

  3. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

  4. Codeforces#441 Div.2 四小题

    Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...

  5. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  6. codeforces #578(Div.2)

    codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...

  7. codeforces #577(Div.2)

    codeforces #577(Div.2) A  Important Exam A class of students wrote a multiple-choice test. There are ...

  8. codeforces #332 div 2 D. Spongebob and Squares

    http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...

  9. Codeforces Round #221 (Div. 1) B. Maximum Submatrix 2 dp排序

    B. Maximum Submatrix 2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...

随机推荐

  1. xpath 操作XML

    1.xpath 操作XML,底下部分代码被注释了,但是是完整功能,去除注释是正常使用的(有写命名和其他冲突,所以注释了) 总体有:完整读取xml,对xml的增删改查,对xml的特定操作 using S ...

  2. C# 异步操作

    在程序中,普通的方法是单线程的.但中途如果有大型的操作,比如读取大文件,大批量操作数据库,网络传输等,都会导致程序阻塞,表现在界面上就是程序卡或者死掉,界面元素不动了,不响应了.C#异步调用很好的解决 ...

  3. HDU 3359 Kind of a Blur(高斯消元)

    题意: H * W (W,H <= 10) 的矩阵A的某个元素A[i][j],从它出发到其他点的曼哈顿距离小于等于D的所有值的和S[i][j]除上可达点的数目,构成了矩阵B.给定矩阵B,求矩阵A ...

  4. extjs中gridpanel动态显示/隐藏列

    在extjs3中,大家知道用 myGrid.getColumnModel().setHidden(i,true);但到了4.0后,已经没有getColumnModel这个方法了,我们在Ext.pane ...

  5. 谨慎使用php的strtotime()函数

    我们在日常业务中,针对业务量,经常会采用对数据库按时间做横向分表,分表后的查询往往会涉及到时间问题.例如,我们想查询某个用户距离当前时间1个月的订单情况,在这个时候,我们有些会用到strtotime( ...

  6. 完美PNG半透明窗体解决方案

    当年Vista系统刚出来的时候,最吸引人的莫过于半透明磨砂的窗体界面了,迷倒了多少人.这个界面技术随即引发了编程界的一阵骚动,很多人都在问:如何实现这一界面效果?当然,在Vista下倒是很简单,系统本 ...

  7. python运维开发之路第一天

    一.python安装及环境变量配置 1.windows7安装python 1)下载地址:https://www.python.org/downloads/windows/ 如下图: 注意:下载,用代理 ...

  8. lsmod

    http://blog.csdn.net/yuan892173701/article/details/8960607 抽空写下

  9. Solr4.8.0源码分析(22)之SolrCloud的Recovery策略(三)

    Solr4.8.0源码分析(22)之SolrCloud的Recovery策略(三) 本文是SolrCloud的Recovery策略系列的第三篇文章,前面两篇主要介绍了Recovery的总体流程,以及P ...

  10. 转:《IIC时序》

    I2C(Inter-Integrated Circuit)总线是一种由PHILIPS公司开发的两线式串行总线,用于连接微控制器及其外围设备.I2C总线产生于在80年代,最初为音频和视频设备开发,如今主 ...