题目连接:http://codeforces.com/contest/448

A:给你一些奖杯与奖牌让你推断能不能合法的放在给定的架子上。假设能够就是YES否则就是NO。

<span style="font-size:18px;">#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define eps 1e-12
///#define M 1000100
///#define LL __int64
#define LL long long
///#define INF 0x7ffffff
#define INF 0x3f3f3f3f
#define PI 3.1415926535898
#define zero(x) ((fabs(x)<eps)?0:x) using namespace std; const int maxn = 100010; int num[maxn]; int main()
{
int a1, a2, a3;
int b1, b2, b3;
int n;
while(cin >>a1)
{
cin >>a2>>a3;
cin >>b1>>b2>>b3;
cin >>n;
int sum1 = 0;
sum1 += a1;
sum1 += a2;
sum1 += a3;
int sum2 = 0;
sum2 += b1;
sum2 += b2;
sum2 += b3;
int x = sum1/5;
if(sum1%5) x++;
int y = sum2/10;
if(sum2%10) y++;
if(x+y<= n) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}</span>

B:给你两个字符串,推断假设让s串变成t串须要什么操作。

假设仅仅是删除一些字母就能够得到输出:automaton。假设仅仅是通过调换字母的顺序就输出:array。如既要删除字母又要调换顺序输出:both。假设须要加入新的字母输出:need tree。

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define eps 1e-12
///#define M 1000100
///#define LL __int64
#define LL long long
///#define INF 0x7ffffff
#define INF 0x3f3f3f3f
#define PI 3.1415926535898
#define zero(x) ((fabs(x)<eps)?0:x) using namespace std; const int maxn = 110; char s1[maxn];
char s2[maxn];
int vis[maxn];
int num[maxn]; int main()
{
while(cin >>s1)
{
cin >>s2;
int len1 = strlen(s1);
int len2 = strlen(s2);
memset(vis, 0, sizeof(vis));
memset(num, 0, sizeof(num));
for(int i = 0; i < len1; i++) vis[s1[i]-'a']++;
int flag1 = 0;
for(int i = 0; i < (len1-len2); i++)
{
int flag = 0;
for(int j = 0; j < len2; j++)
{
if(s1[i+j] != s2[j])
{
flag = 1;
break;
}
}
if(!flag)
{
flag1 = 1;
break;
}
}
int flag2 = 0;
for(int i = 0; i < len2; i++) num[s2[i]-'a']++;
for(int i = 0; i < 26; i++)
{
if(num[i] > vis[i])
{
flag2 = 1;
break;
}
}
if(flag2) cout<<"need tree"<<endl;
else if(flag1) cout<<"automaton"<<endl;
else if(len1 == len2 && !flag2) cout<<"array"<<endl;
else
{
int top = 0;
for(int i = 0; i < len1; i++) if(s1[i] == s2[top]) top++;
if(top == len2) cout<<"automaton"<<endl;
else cout<<"both"<<endl;
}
}
}

C给你一串数字代表木板的高度,每块木板的宽度都为1。

让你算出最少须要多少次能够把木板染完颜色。染得时候能够每次染长度为1的一横行(能够多个连续的木板)或者能够竖着然这个一块木板。每一个木板能够反复染色。

思路是:dp[i][j]表示染到第i块木板的时候染了j次横的。

须要注意的是要从后向前的dp。

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define eps 1e-12
///#define M 1000100
///#define LL __int64
#define LL long long
///#define INF 0x7ffffff
#define INF 0x3f3f3f3f
#define PI 3.1415926535898
#define zero(x) ((fabs(x)<eps)?0:x) using namespace std; const int maxn = 5010;
int dp[maxn][maxn];
int num[maxn];
int main()
{
int n;
while(cin >>n)
{
num[0] = 0;
for(int i = 1; i <= n; i++) scanf("%d",&num[i]);
for(int i = 0; i <= n; i++) dp[n][i] = 0;
for(int i = n; i >= 1; i--)
{
for(int j = 0; j < i; j++)
{
if(num[i] <= num[j])
{
dp[i-1][j] = dp[i][i];
continue;
}
dp[i-1][j] = min(dp[i][j]+1, dp[i][i]+num[i]-num[j]);
} }
cout<<dp[0][0]<<endl;
}
return 0;
}

D给你n。m,k。n*m的矩阵中的每一个元素是i,j的成绩。然后让你求一个x满足在这个n*m的矩阵中有k个元素小于x。

思路二分枚举x,范围是1-n*m。

可是这里要高速求出小于x的数的个数。

for(int i = 1; i <= n; i++) ans += min(m, mid/i);这个能够高速的统计出这一行中有多少个元素是小于x的。

#include <algorithm>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#define eps 1e-12
///#define M 1000100
///#define LL __int64
#define LL long long
///#define INF 0x7ffffff
#define INF 0x3f3f3f3f
#define PI 3.1415926535898
#define zero(x) ((fabs(x)<eps)?0:x) using namespace std; const int maxn = 5010;
int dp[maxn][maxn];
int num[maxn];
int main()
{
LL n, m, k;
while(cin >>n>>m>>k)
{
LL l = 1;
LL r = n*m;
while(l < r)
{
LL mid = (l+r)>>1;
LL ans = 0;
for(int i = 1; i <= n; i++) ans += min(m, mid/i);
if(ans >= k) r = mid;
else if(ans < k) l = mid+1;
}
cout<<r<<endl;
}
}

Codeforces Round #256 (Div. 2)A-D的更多相关文章

  1. Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)

    转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...

  2. Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)

    题目链接:http://codeforces.com/contest/448/problem/B --------------------------------------------------- ...

  3. Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)

    解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 ...

  4. Codeforces Round #256 (Div. 2) 题解

    Problem A: A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. Codeforces Round #256 (Div. 2) A. Rewards

    A. Rewards time limit per test 1 second memory limit per test 256 megabytes input standard input out ...

  6. Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法

     D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...

  7. Codeforces Round #256 (Div. 2) D. Multiplication Table

    主题链接:http://codeforces.com/contest/448/problem/D 思路:用二分法 code: #include<cstdio> #include<cm ...

  8. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)

    解题报告 意思就是说有n行柜子,放奖杯和奖牌.要求每行柜子要么全是奖杯要么全是奖牌,并且奖杯每行最多5个,奖牌最多10个. 直接把奖杯奖牌各自累加,分别出5和10,向上取整和N比較 #include ...

  9. Codeforces Round #256 (Div. 2) D. Multiplication Table 很有想法的一个二分

    D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...

随机推荐

  1. Windows下Apache2.2+PHP5安装步骤

    Windows下Apache2.2+PHP5安装 初学者在学习PHP的时候可能都会遇到安装Apache和PHP不成功的问题,于是很多开发者便选择了集成包,一键安装好Apache+PHP+MySQL.但 ...

  2. Tasker, Android系统增强神器, 变量汇总

    http://tasker.dinglisch.net/userguide_summary.html#variables.html http://tasker.dinglisch.net/usergu ...

  3. springMvc的一些简介 和基于xml的handlerMapping基本流程

    其它步骤就不在介绍了 在大多数情况,都会使用基于annotation的方式进行HandlerMapping处理,在这里基于对这个流程的了解,就采用了基于xml配置了一个HandlerMapping & ...

  4. 计蒜之道 初赛 第三场 题解 Manacher o(n)求最长公共回文串 线段树

    腾讯手机地图 腾讯手机地图的定位功能用到了用户手机的多种信号,这当中有的信号的作用范围近.有的信号作用的范围则远一些.有的信号相对于用户在不同的方位强度是不同的,有的则是在不论什么一个方向上信号强度都 ...

  5. java自动识别上传的apk版本号

    import java.util.List; public class ApkInfo { private String versionCode; private String versionName ...

  6. iTunes Connect App Video

    系统要求: 系统升级为 OS X Yosemote 版本 10.10 (正式版已经发布更新) 录制工具: QuickTime Player 版本 10.4 (833) 操作流程: 1. 设备数据线连接 ...

  7. (转)Sql Server 快速查看表结构(表描述及字段说明)

    --表描述 SELECT tbs.name 表名,ds.value 描述 FROM sys.extended_properties ds LEFT JOIN sysobjects tbs ON ds. ...

  8. 学会了 Vim 还有必要用 GitHub Atom 或者 Sublime Text 么?

    亦俊 ,90后,Vim 专栏作者 563 人赞同 Vim 知乎专栏:http://zhuanlan.zhihu.com/hack-vim 用过 [ Visual Studio 2015 ] [ Sub ...

  9. 批量删除linux的文件;find方法批量删除文件;find查找某时间段内的所有文件

    1.如图所示,有大量文件夹,想批量删除它们 2.使用命令 find . -maxdepth 1  -regex ".*ws.*" 可以批量找到他们.maxdepth值为1表示只在当 ...

  10. 数学图形(1.28) EPI线

    貌似由双曲线组成的图形.有时会像个自行车的轮子. 相关软件参见:数学图形可视化工具,使用自己定义语法的脚本代码生成数学图形.该软件免费开源.QQ交流群: 367752815 #http://www.m ...