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

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

  1. <span style="font-size:18px;">#include <algorithm>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <iomanip>
  6. #include <stdio.h>
  7. #include <string>
  8. #include <queue>
  9. #include <cmath>
  10. #include <stack>
  11. #include <map>
  12. #include <set>
  13. #define eps 1e-12
  14. ///#define M 1000100
  15. ///#define LL __int64
  16. #define LL long long
  17. ///#define INF 0x7ffffff
  18. #define INF 0x3f3f3f3f
  19. #define PI 3.1415926535898
  20. #define zero(x) ((fabs(x)<eps)?0:x)
  21.  
  22. using namespace std;
  23.  
  24. const int maxn = 100010;
  25.  
  26. int num[maxn];
  27.  
  28. int main()
  29. {
  30. int a1, a2, a3;
  31. int b1, b2, b3;
  32. int n;
  33. while(cin >>a1)
  34. {
  35. cin >>a2>>a3;
  36. cin >>b1>>b2>>b3;
  37. cin >>n;
  38. int sum1 = 0;
  39. sum1 += a1;
  40. sum1 += a2;
  41. sum1 += a3;
  42. int sum2 = 0;
  43. sum2 += b1;
  44. sum2 += b2;
  45. sum2 += b3;
  46. int x = sum1/5;
  47. if(sum1%5) x++;
  48. int y = sum2/10;
  49. if(sum2%10) y++;
  50. if(x+y<= n) cout<<"YES"<<endl;
  51. else cout<<"NO"<<endl;
  52. }
  53. return 0;
  54. }</span>

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

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

  1. #include <algorithm>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <iomanip>
  6. #include <stdio.h>
  7. #include <string>
  8. #include <queue>
  9. #include <cmath>
  10. #include <stack>
  11. #include <map>
  12. #include <set>
  13. #define eps 1e-12
  14. ///#define M 1000100
  15. ///#define LL __int64
  16. #define LL long long
  17. ///#define INF 0x7ffffff
  18. #define INF 0x3f3f3f3f
  19. #define PI 3.1415926535898
  20. #define zero(x) ((fabs(x)<eps)?0:x)
  21.  
  22. using namespace std;
  23.  
  24. const int maxn = 110;
  25.  
  26. char s1[maxn];
  27. char s2[maxn];
  28. int vis[maxn];
  29. int num[maxn];
  30.  
  31. int main()
  32. {
  33. while(cin >>s1)
  34. {
  35. cin >>s2;
  36. int len1 = strlen(s1);
  37. int len2 = strlen(s2);
  38. memset(vis, 0, sizeof(vis));
  39. memset(num, 0, sizeof(num));
  40. for(int i = 0; i < len1; i++) vis[s1[i]-'a']++;
  41. int flag1 = 0;
  42. for(int i = 0; i < (len1-len2); i++)
  43. {
  44. int flag = 0;
  45. for(int j = 0; j < len2; j++)
  46. {
  47. if(s1[i+j] != s2[j])
  48. {
  49. flag = 1;
  50. break;
  51. }
  52. }
  53. if(!flag)
  54. {
  55. flag1 = 1;
  56. break;
  57. }
  58. }
  59. int flag2 = 0;
  60. for(int i = 0; i < len2; i++) num[s2[i]-'a']++;
  61. for(int i = 0; i < 26; i++)
  62. {
  63. if(num[i] > vis[i])
  64. {
  65. flag2 = 1;
  66. break;
  67. }
  68. }
  69. if(flag2) cout<<"need tree"<<endl;
  70. else if(flag1) cout<<"automaton"<<endl;
  71. else if(len1 == len2 && !flag2) cout<<"array"<<endl;
  72. else
  73. {
  74. int top = 0;
  75. for(int i = 0; i < len1; i++) if(s1[i] == s2[top]) top++;
  76. if(top == len2) cout<<"automaton"<<endl;
  77. else cout<<"both"<<endl;
  78. }
  79. }
  80. }

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

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

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

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

  1. #include <algorithm>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <iomanip>
  6. #include <stdio.h>
  7. #include <string>
  8. #include <queue>
  9. #include <cmath>
  10. #include <stack>
  11. #include <map>
  12. #include <set>
  13. #define eps 1e-12
  14. ///#define M 1000100
  15. ///#define LL __int64
  16. #define LL long long
  17. ///#define INF 0x7ffffff
  18. #define INF 0x3f3f3f3f
  19. #define PI 3.1415926535898
  20. #define zero(x) ((fabs(x)<eps)?0:x)
  21.  
  22. using namespace std;
  23.  
  24. const int maxn = 5010;
  25. int dp[maxn][maxn];
  26. int num[maxn];
  27. int main()
  28. {
  29. int n;
  30. while(cin >>n)
  31. {
  32. num[0] = 0;
  33. for(int i = 1; i <= n; i++) scanf("%d",&num[i]);
  34. for(int i = 0; i <= n; i++) dp[n][i] = 0;
  35. for(int i = n; i >= 1; i--)
  36. {
  37. for(int j = 0; j < i; j++)
  38. {
  39. if(num[i] <= num[j])
  40. {
  41. dp[i-1][j] = dp[i][i];
  42. continue;
  43. }
  44. dp[i-1][j] = min(dp[i][j]+1, dp[i][i]+num[i]-num[j]);
  45. }
  46.  
  47. }
  48. cout<<dp[0][0]<<endl;
  49. }
  50. return 0;
  51. }

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的。

  1. #include <algorithm>
  2. #include <iostream>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <iomanip>
  6. #include <stdio.h>
  7. #include <string>
  8. #include <queue>
  9. #include <cmath>
  10. #include <stack>
  11. #include <map>
  12. #include <set>
  13. #define eps 1e-12
  14. ///#define M 1000100
  15. ///#define LL __int64
  16. #define LL long long
  17. ///#define INF 0x7ffffff
  18. #define INF 0x3f3f3f3f
  19. #define PI 3.1415926535898
  20. #define zero(x) ((fabs(x)<eps)?0:x)
  21.  
  22. using namespace std;
  23.  
  24. const int maxn = 5010;
  25. int dp[maxn][maxn];
  26. int num[maxn];
  27. int main()
  28. {
  29. LL n, m, k;
  30. while(cin >>n>>m>>k)
  31. {
  32. LL l = 1;
  33. LL r = n*m;
  34. while(l < r)
  35. {
  36. LL mid = (l+r)>>1;
  37. LL ans = 0;
  38. for(int i = 1; i <= n; i++) ans += min(m, mid/i);
  39. if(ans >= k) r = mid;
  40. else if(ans < k) l = mid+1;
  41. }
  42. cout<<r<<endl;
  43. }
  44. }

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. April Fools Day Contest 2016 G. You're a Professional

    G. You're a Professional 题目连接: http://www.codeforces.com/contest/656/problem/G Description A simple ...

  2. WinDbg-如何抓取dump文件

    这要分两种情况:第一种情况:如果是Vista或者是Windows2008操作系统就是一个简单的事情,在任务管理器中,切换到"进程"选项卡,右键点击你想要创建dump文件的进程,然后 ...

  3. Visual Studio 2015创建Shared Project时出错

    今天使用Visual Studio 2015创建共享项目的时候发现如下错误: 网上搜了一下,发现了同样有人问这个问题的问题:Why can't I create Shared Project in V ...

  4. Unity3D架构设计NavMesh寻路(未完待续)

    国庆闲来没事把NavMesh巩固一下.以Unity3D引擎为例写一个底层c# NavMesh寻路.由于Unity3D中本身自带的NavMesh寻路不能非常好的融入到游戏项目其中,所以重写一个NavMe ...

  5. How to implement *All-Digital* analog-to-digital converters in FPGAs and ASICs

    When we engineers look at the complexity of system design these days, we are challenged with crammin ...

  6. RFID Reader ICs

    http://www.advanide.com/readeric.htm Low Frequency Reader ICs Manufacturer Product Frequency ISO Com ...

  7. iptables学习与研究(使用LOG记录失败日志)

    原文地址: http://blog.csdn.net/fafa211/article/details/2307581 通常情况下,iptables的默认政策为DROP,不匹配的数据包将被直接丢弃.但在 ...

  8. 【QQ输入法】QQ输入法输入的英文字母顺便空格很大

    正常的输入出来是这个样子的: 现在变成了这个样子: 怎么解决这个问题呢: 快捷键 shift+空格   即可解决

  9. 【java】【mysql】存储微信表情emoji表情

    java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for colum n 'name' at row 1 at com ...

  10. Unity3D开发之查找面板上某个脚本(包含Missing)

    有时候我们须要知道某个脚本在场景上面哪里用到,或者那个脚本被删除了但又没有把相关游戏场景的关联东西删掉,那样我们就要一个脚本来查找一下了: PS:以下两个脚本都要放到assets/Editor以下哦. ...