A

无trick水题。。。

 /*
* Author: Plumrain
* Created Time: 2013-12-24 22:26
* File Name: B.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility> using namespace std; #define clr0(x) memset(x, 0, sizeof(x))
#define clr1(x) memset(x, -1, sizeof(x))
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(t) t.begin(),t.end()
#define INF 999999999999999999
#define zero(x) (((x)>0?(x):-(x))<eps)
#define out(x) cout<<#x<<":"<<(x)<<endl
#define tst(a) cout<<a<<" "
#define tst1(a) cout<<#a<<endl
#define CINBEQUICKER std::ios::sync_with_stdio(false) const double eps = 1e-;
const double PI = atan(1.0)*;
const int inf = / ; typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef long long int64; inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;} int ru[], chu[]; int main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
// std::ios::sync_with_stdio(false);
int n, m;
while (scanf ("%d%d", &n , &m) != EOF){
int t1, t2, w;
clr0 (chu); clr0 (ru);
for (int i = ; i < m; ++ i){
scanf ("%d%d%d", &t1, &t2, &w);
chu[--t1] += w;
ru[--t2] += w;
}
int ans = ;
for (int i = ; i < n; ++ i)
ans += abs(chu[i] - ru[i]);
printf ("%d\n", ans / );
}
return ;
}

B

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

 /*
* Author: Plumrain
* Created Time: 2013-12-24 22:26
* File Name: B.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility> using namespace std; #define clr0(x) memset(x, 0, sizeof(x))
#define clr1(x) memset(x, -1, sizeof(x))
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(t) t.begin(),t.end()
#define INF 999999999999999999
#define zero(x) (((x)>0?(x):-(x))<eps)
#define out(x) cout<<#x<<":"<<(x)<<endl
#define tst(a) cout<<a<<" "
#define tst1(a) cout<<#a<<endl
#define CINBEQUICKER std::ios::sync_with_stdio(false) const double eps = 1e-;
const double PI = atan(1.0)*;
const int inf = / ; typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef long long int64; inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;} int ru[], chu[]; int main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
// std::ios::sync_with_stdio(false);
int n, m;
while (scanf ("%d%d", &n , &m) != EOF){
int t1, t2, w;
clr0 (chu); clr0 (ru);
for (int i = ; i < m; ++ i){
scanf ("%d%d%d", &t1, &t2, &w);
chu[--t1] += w;
ru[--t2] += w;
}
int ans = ;
for (int i = ; i < n; ++ i)
ans += abs(chu[i] - ru[i]);
printf ("%d\n", ans / );
}
return ;
}

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

 /*
* Author: Plumrain
* Created Time: 2013-12-25 14:09
* File Name: C.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility> using namespace std; #define clr0(x) memset(x, 0, sizeof(x))
#define clr1(x) memset(x, -1, sizeof(x))
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(t) t.begin(),t.end()
#define INF 999999999999999999
#define zero(x) (((x)>0?(x):-(x))<eps)
#define out(x) cout<<#x<<":"<<(x)<<endl
#define tst(a) cout<<a<<" "
#define tst1(a) cout<<#a<<endl
#define CINBEQUICKER std::ios::sync_with_stdio(false) const double eps = 1e-;
const double PI = atan(1.0)*;
const int inf = / ; typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef long long int64; inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;} bool del[];
string temp = "";
map<int, string> mp; void gao(string s)
{
stringstream stm(s);
int num; stm >> num;
int yu = num % ;
if (!mp.count(yu)) mp[yu] = s;
} int main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
// std::ios::sync_with_stdio(false);
mp.clear();
string tt = "";
gao(tt);
while (next_permutation(tt.begin(), tt.end())) gao(tt); string s;
while (cin >> s){
clr0 (del);
string ss; ss.clear();
int n = sz(s), cnt = ;
for (int i = ; i < n; ++ i){
if (s[i] == ''){
++ cnt; continue;
}
bool ok = ;
for (int j = ; j < ; ++ j) if (s[i] == temp[j] && !del[j]){
del[j] = ; ok = ;
}
if (!ok) ss.pb (s[i]);
} int len = sz(ss);
if (!len){
ss = mp[];
for (int i = ; i < cnt; ++ i) ss.pb ('');
cout << ss << endl;
continue;
}
for (int i = ; i < cnt; ++ i) ss.pb ('');
len = sz(ss);
int flag = ;
for (int i = ; i < len; ++ i)
flag = (flag* + ss[i] - '') % ;
flag = flag * % ;
ss += mp[( - flag) % ];
cout << ss << endl;
}
return ;
}

D

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

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

tag:dp, think, good

 /*
* Author: Plumrain
* Created Time: 2013-12-26 12:49
* File Name: D.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cctype>
#include <ctime>
#include <utility> using namespace std; #define clr0(x) memset(x, 0, sizeof(x))
#define clr1(x) memset(x, -1, sizeof(x))
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(t) t.begin(),t.end()
#define INF 999999999999999999
#define zero(x) (((x)>0?(x):-(x))<eps)
#define out(x) cout<<#x<<":"<<(x)<<endl
#define tst(a) cout<<a<<" "
#define tst1(a) cout<<#a<<endl
#define CINBEQUICKER std::ios::sync_with_stdio(false) const double eps = 1e-;
const double PI = atan(1.0)*;
const int inf = / ; typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef long long int64; inline int Mymod (int a, int b) {int x=a%b; if(x<) x+=b; return x;} int n, m;
int p[][], num[];
char v[][]; int main()
{
// freopen("a.in","r",stdin);
//freopen("a.out","w",stdout);
// std::ios::sync_with_stdio(false);
while (scanf ("%d%d", &n, &m) != EOF){
string s;
for (int i = ; i < n; ++ i)
scanf ("%s", v[i]);
for (int i = ; i < n; ++ i){
int tmp = m;
for (int j = m-; j >= ; -- j){
if (v[i][j] == '')
tmp = j, p[i][j] = j;
else
p[i][j] = tmp;
}
}
int ans = ;
for (int i = ; i < m; ++ i){
clr0 (num);
for (int j = ; j < n; ++ j) num[p[j][i] - i] ++;
int pos = ;
while (pos && num[pos] == ) -- pos;
int cnt = ;
while (pos){
if (num[pos]) cnt += num[pos];
ans = max(cnt*pos, ans);
-- pos;
}
}
printf ("%d\n", ans);
}
return ;
}

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. 本地tomcat访问mysql数据库

    虽然以前经常听人说起过tomcat,但是今天头一次使用tomcat. 1.Tomcat的安装过程: 首先应该从Apache官方网站上下载是用于Windows的.zip压缩包. 下面是相应的下载链接: ...

  2. 子树大小平衡树(Size Balanced Tree,SBT)操作模板及杂谈

    基础知识(包括但不限于:二叉查找树是啥,SBT又是啥反正又不能吃,平衡树怎么旋转,等等)在这里就不(lan)予(de)赘(duo)述(xie)了. 先贴代码(数组模拟): int seed; int ...

  3. 关键字throw(something)限制

    C++函数后加关键字throw(something)限制,是对这个函数的异常安全性作出限制.void f() throw() 表示f不允许抛出任何异常,即f是异常安全的.void f() throw( ...

  4. vs2008 下编译jrtplib-3.9.0成功

    jrtplib-3.9.0的编译,终于搞通了.网上搜集了很多资料,自己也调试了很久. 首先,jrtplib-3.9.0是什么不用多说吧,它是一个很牛的老外用C++写的一个开源的RTP协议库,用它可以进 ...

  5. 【BZOJ2809】【splay启发式合并】dispatching

    Description 在一个忍者的帮派里,一些忍者们被选中派遣给顾客,然后依据自己的工作获取报偿.在这个帮派里,有一名忍者被称之为 Master.除了 Master以外,每名忍者都有且仅有一个上级. ...

  6. java数据类型学习

    java数据类型基本分为两类: 一类为基本数据类型: 数值类型: 整数类型:byte.short.int.long 浮点类型:float.double 字符类型:char 布尔类型:boolean 一 ...

  7. 将fastjson元素转化为String[]

    在fastjson中如果JSONObject中添加了 String[] 类型的元素 例如 JSONObject jo = new JSONObject(); String[] array = {&qu ...

  8. cc命令

    多数UNIX平台都通过CC调用它们的C编译程序.除标准和CC以外,LINUX和FREEBSD还支持gcc. 基本的编译命令有以下几种: 1. -c 编译产生对象文件(*.obj)而不链接成可执行文件, ...

  9. hdu 3308

    终于A了,我好想砍人,虽然这是一道基础的区间合并.但是这错误我也是醉了. 错误我表在注释里. 题目意思不多说,sha崽题目出的很简洁. #include <iostream>#includ ...

  10. 20款jquery下拉导航菜单特效代码分享

    20款jquery下拉导航菜单特效代码分享 jquery仿京东商城左侧分类导航下拉菜单代码 jQuery企业网站下拉导航菜单代码 jQuery css3黑色的多级导航菜单下拉列表代码 jquery响应 ...