2016 Al-Baath University Training Camp Contest-1

A题:http://codeforces.com/gym/101028/problem/A

题意:比赛初始值是1500,变化了几次,得到的正确结果和bug后的是否相等。(Tourist大佬好 Y(^o^)Y)

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin>>t;
  9. while(t--) {
  10. int n,r;
  11. cin>>n>>r;
  12.  
  13. int sum = ;
  14. for(int i=;i<n;i++)
  15. {
  16. int x;
  17. cin>>x;
  18. sum+=x;
  19. }
  20.  
  21. if(sum==r)
  22. puts("Correct");
  23. else puts("Bug");
  24.  
  25. }
  26. return ;
  27. }

A. Codeforces Rating

B题:http://codeforces.com/gym/101028/problem/B

题意:b,p不分,i,e不分,大小写不分,看两个字符串是不是正确的。

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. char str1[],str2[];
  6.  
  7. int main()
  8. {
  9. int t;
  10. cin>>t;
  11. while(t--) {
  12. scanf("%s%s",str1,str2);
  13.  
  14. int len = strlen(str1);
  15.  
  16. if(strlen(str1)!=strlen(str2)) {
  17. puts("No");
  18. continue;
  19. }
  20.  
  21. for(int i=;i<len;i++)
  22. {
  23. if(str1[i]>='A'&&str1[i]<='Z')
  24. str1[i] = 'a' + str1[i] - 'A';
  25.  
  26. if(str2[i]>='A'&&str2[i]<='Z')
  27. str2[i] = 'a' + str2[i] - 'A';
  28. }
  29.  
  30. bool flag = true;
  31. for(int i=;i<len;i++) {
  32. if(str1[i]!=str2[i]) {
  33. if(str1[i]=='b'&&str2[i]=='p')
  34. continue;
  35. if(str1[i]=='p'&&str2[i]=='b')
  36. continue;
  37. if(str1[i]=='i'&&str2[i]=='e')
  38. continue;
  39. if(str1[i]=='e'&&str2[i]=='i')
  40. continue;
  41. flag = false;
  42. break;
  43. }
  44. }
  45.  
  46. if(flag)
  47. puts("Yes");
  48. else puts("No");
  49.  
  50. }
  51. return ;
  52. }

B. Bonapity

C题:http://codeforces.com/gym/101028/problem/C

题意:已知A,B,求C有多少种情况满足这个式子:

比赛的时候,很多同学没有看到取模,用java干;

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin>>t;
  9. while(t--) {
  10. int len;
  11. cin>>len;
  12. int a[],b[];
  13. char stra[],strb[];
  14. scanf("%s%s",stra,strb);
  15. for(int i=;i<len;i++)
  16. {
  17. a[i] = stra[i]-'';
  18. b[i] = strb[i]-'';
  19. }
  20. unsigned long long ans = ;
  21. bool flag = true;
  22. for(int i=;i<len;i++) {
  23. if(a[i]==&&b[i]==)
  24. continue;
  25. if(a[i]==&&b[i]==)
  26. continue;
  27. if(a[i]==&&b[i]==){
  28. flag = false;
  29. break;
  30. }
  31. if(a[i]==&&b[i]==)
  32. ans = ans*%;
  33. }
  34. if(flag)
  35. cout<<ans<<endl;
  36. else puts("IMPOSSIBLE");
  37. }
  38.  
  39. return ;
  40. }

C. A or B Equals C

D题:http://codeforces.com/gym/101028/problem/D

题意:画图

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. char maps[][];
  6.  
  7. int main()
  8. {
  9. int t;
  10. scanf("%d",&t);
  11. while(t--)
  12. {
  13. memset(maps,'.',sizeof(maps));
  14.  
  15. int r,c,n;
  16. cin>>r>>c>>n;
  17.  
  18. while(n--)
  19. {
  20.  
  21. int r1, c1, r2, c2;
  22. char x;
  23. cin>>r1>>c1>>r2>>c2>>x;
  24.  
  25. for(int i=r1; i<=r2; i++)
  26. {
  27. for(int j=c1; j<=c2; j++)
  28. {
  29. maps[i][j] = x;
  30. }
  31. }
  32.  
  33. }
  34. for(int i=; i<=r; i++)
  35. {
  36. for(int j=; j<=c; j++)
  37. printf("%c",maps[i][j]);
  38. puts("");
  39. }
  40.  
  41. }
  42. return ;
  43. }

D. X and paintings

E题:http://codeforces.com/gym/101028/problem/E

题意:n个数的最大公约数

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int inf = 0x3f3f3f3f;
  6.  
  7. int main()
  8. {
  9. int t;
  10. int a[];
  11. scanf("%d",&t);
  12. while(t--) {
  13. int minx = inf;
  14. int n;
  15. scanf("%d",&n);
  16. for(int i=;i<n;i++) {
  17. scanf("%d",&a[i]);
  18. minx = min(minx,a[i]);
  19. }
  20.  
  21. int k;
  22. for(k=minx;k>=;k--) {
  23. bool flag = true;
  24. for(int i=;i<n;i++) {
  25. if(a[i]%k!=) {
  26. flag = false;
  27. break;
  28. }
  29. }
  30. if(flag)
  31. break;
  32. }
  33. int num = ;
  34. for(int i=;i<n;i++)
  35. num+=(a[i]/k);
  36. printf("%d %d\n",k,num);
  37.  
  38. }
  39. return ;
  40. }

E. Teams

F题:http://codeforces.com/gym/101028/problem/F

题意:字符串匹配(朴素匹配就ok了)

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. char str1[],str2[];
  5. int main()
  6. {
  7. int t;
  8. cin>>t;
  9. while(t--)
  10. {
  11. scanf("%s%s",str1,str2);
  12. int len = strlen(str1);
  13.  
  14. char op[][];
  15. memset(op,,sizeof(op));
  16.  
  17. for(int i=; i<; i++)
  18. {
  19. int k=;
  20. for(int j=; j<; j++)
  21. {
  22. if(i!=j)
  23. op[i][k++] = str2[j];
  24. }
  25. }
  26.  
  27. // for(int i=0;i<4;i++) {
  28. // for(int j=0;j<3;j++)
  29. // printf("%c",op[i][j]);
  30. // puts("");
  31. // }
  32.  
  33. bool good = false;
  34. for(int i=; i<len-; i++)
  35. {
  36. if(str1[i]==str2[]&&str1[i+]==str2[]&&str1[i+]==str2[]&&str1[i+]==str2[])
  37. {
  38. good = true;
  39. break;
  40. }
  41. }
  42.  
  43. if(good)
  44. {
  45. puts("good");
  46. continue;
  47. }
  48.  
  49. bool al = false;
  50. for(int i=; i<len-; i++)
  51. {
  52. if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
  53. {
  54. al = true;
  55. break;
  56. }
  57. }
  58.  
  59. if(al)
  60. {
  61. puts("almost good");
  62. continue;
  63. }
  64.  
  65. al = false;
  66. for(int i=; i<len-; i++)
  67. {
  68. if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
  69. {
  70. al = true;
  71. break;
  72. }
  73. }
  74.  
  75. if(al)
  76. {
  77. puts("almost good");
  78. continue;
  79. }
  80.  
  81. al = false;
  82. for(int i=; i<len-; i++)
  83. {
  84. if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
  85. {
  86. al = true;
  87. break;
  88. }
  89. }
  90.  
  91. if(al)
  92. {
  93. puts("almost good");
  94. continue;
  95. }
  96.  
  97. al = false;
  98. for(int i=; i<len-; i++)
  99. {
  100. if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
  101. {
  102. al = true;
  103. break;
  104. }
  105. }
  106.  
  107. if(al)
  108. {
  109. puts("almost good");
  110. continue;
  111. }
  112.  
  113. puts("none");
  114.  
  115. }
  116. return ;
  117. }

F. Good Words

G题:http://codeforces.com/gym/101028/problem/G

题意:从左上角砸东西到目的地,途中碰壁。看可以不可以砸到目标。和省赛的球的碰撞类似。

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin>>t;
  9. while(t--) {
  10.  
  11. int h,w,d;
  12. cin>>h>>w>>d;
  13.  
  14. int x = (h-)/(w-); //x个单周期
  15. int mod = (h-)%(w-);
  16.  
  17. int md;
  18. if(x%==)
  19. md = + mod;
  20. else md = w - mod ;
  21.  
  22. if(md==d)
  23. puts("Yes");
  24. else puts("No");
  25.  
  26. }
  27. return ;
  28. }

G. The Tower of Evil

H题:http://codeforces.com/gym/101028/problem/H

做到这里的时候,脑子已经晕掉了,题目也没怎么看清楚。

题意:n长的河流,两个人的速度是d,r,在start的位置不标记,求第一次踩到对方标记的时间。

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int v1[];
  6. int v2[];
  7.  
  8. int main()
  9. {
  10. int t;
  11. cin>>t;
  12. while(t--)
  13. {
  14. memset(v1,,sizeof(v1));
  15. memset(v2,,sizeof(v2));
  16. int n,d,r;
  17. cin>>n>>d>>r;
  18.  
  19. int ans = ;
  20. int td = d;
  21. int tr = r;
  22. v1[td] = ;
  23. v2[tr] = ;
  24. while(true)
  25. {
  26. if(v2[td]==true||v1[tr]==true)
  27. {
  28. break;
  29. }
  30. ans++;
  31. td = (td + d)%n;
  32. tr = (tr + r)%n;
  33. v1[td] = true;
  34. v2[tr] = true;
  35. }
  36. printf("%d\n",ans);
  37.  
  38. }
  39. return ;
  40. }

H. The Endless River

I题:http://codeforces.com/gym/101028/problem/I

题意:屋顶有漏洞,用k个布去补洞,其中最长的布,使其最短。

二分啊!

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int a[];
  6. int n,k;
  7. int maxx;
  8. bool calc(int x) {
  9. int cur = ;
  10. for(int i=;i<k;i++) {
  11. if(cur==)
  12. cur = cur + a[] + x -;
  13. else {
  14. for(int i=;i<n;i++) {
  15. if(a[i]>cur)
  16. {
  17. cur = a[i];
  18. break;
  19. }
  20. }
  21. cur = cur + x -;
  22. }
  23. }
  24. if(cur>=a[n-])
  25. return true;
  26. return false;
  27. }
  28.  
  29. int main()
  30. {
  31. int t;
  32. cin>>t;
  33. while(t--) {
  34. cin>>n>>k;
  35. for(int i=;i<n;i++)
  36. scanf("%d",&a[i]);
  37. maxx = a[n-];
  38. int l=;
  39. int r=a[n-]/k+;
  40. while(l<r) {
  41. int m = (r+l)/;
  42. if(calc(m))
  43. r=m;
  44. else l = m+;
  45. }
  46. printf("%d\n",l);
  47. }
  48. return ;
  49. }

I. March Rain

J题:http://codeforces.com/gym/101028/problem/J

题意:

一个数列a,他的最大的2i 的因子,由 i 组成的一个数列。

找一些a,他是递增的基础上,i 之和最大。

dp啊!

  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int a[];
  6. int as[];
  7. int b[];
  8. int dp[];
  9.  
  10. int main()
  11. {
  12. int t;
  13. cin>>t;
  14. while(t--)
  15. {
  16. memset(b,,sizeof(b));
  17. memset(dp,,sizeof(dp));
  18.  
  19. int n;
  20. cin>>n;
  21. for(int i=; i<n; i++) {
  22. cin>>a[i];
  23. as[i] = a[i];
  24. }
  25.  
  26. for(int i=; i<n; i++)
  27. {
  28. while(as[i]%==)
  29. {
  30. b[i]++;
  31. as[i] /=;
  32. }
  33. }
  34.  
  35. dp[] = b[];
  36.  
  37. for(int i=; i<n; i++)
  38. {
  39. int k = ;
  40. for(int j=; j<i; j++)
  41. {
  42. if(a[j]<a[i]&&k<dp[j])
  43. {
  44. k = dp[j];
  45. }
  46. }
  47. dp[i] = k+b[i];
  48. }
  49.  
  50. int ans = -;
  51. for(int i=; i<n; i++)
  52. {
  53. ans = max(ans,dp[i]);
  54. }
  55. cout<<ans<<endl;
  56.  
  57. }
  58.  
  59. return ;
  60. }

J. X and Beasts

最后贴一下Rank.

2016 Al-Baath University Training Camp Contest-1的更多相关文章

  1. 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)

    2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) Problem A. M ...

  2. 2016 Al-Baath University Training Camp Contest-1 E

    Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...

  3. 2016 Al-Baath University Training Camp Contest-1 B

    Description A group of junior programmers are attending an advanced programming camp, where they lea ...

  4. 2016 Al-Baath University Training Camp Contest-1 A

    Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...

  5. 2016 Al-Baath University Training Camp Contest-1 J

    Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...

  6. 2016 Al-Baath University Training Camp Contest-1 I

    Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...

  7. 2016 Al-Baath University Training Camp Contest-1 H

     Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...

  8. 2016 Al-Baath University Training Camp Contest-1 G

    Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...

  9. 2016 Al-Baath University Training Camp Contest-1 F

    Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...

随机推荐

  1. 签名:实现参数字典排序,然后拼接为url参数形式

    在很多地方请求参数需要做处理例如: 步骤 1.参数字典排序. 2.拼接字符. /// <summary> /// 生成签名 /// </summary> /// <par ...

  2. RequestContextHolder与RequestContextUtils

    org.springframework.web.servlet.support.RequestContextUtils 在spring-webmvc中, 主要用来获取WebApplicationCon ...

  3. 1 Groovy

    1.1  什么是Groovy? groovy 是一个弱类型,动态语言,并且运行在JVM之上.它与java联系紧密.它是一个功能丰富和友好的java语言. Groovy源代码,通过Groovy编译器编译 ...

  4. 练习五十六:for循环

    某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换 方法一: def o ...

  5. Python学习笔记_零碎知识

    1. 变量本身类型不固定的语言称之为动态语言,与之对应的是静态语言.静态语言在定义变量时必须指定变量类型,如果赋值的时候类型不匹配,就会报错. 2. Python有两种除法: /除法计算结果是浮点数, ...

  6. vue自定义指令拖动div

    钩子函数一个指令定义对象可以提供如下几个钩子函数:bind:只掉用一次,指令第一次绑定到元素是调用,在这里可以进行一次性的初始化设置inserted:被绑定元素插入父节点时调用(仅保证父节点存在,但不 ...

  7. android 闹钟设置问题

    Android开发中,alarmManager在5.0以上系统,启动时间设置无效的问题 做一个app,需要后台保持发送心跳包.由于锁屏后CPU休眠,导致心跳包线程被挂起,所以尝试使用alarmMana ...

  8. 安装Python + Selenium

    1.Python下载与安装‍ 先去Python官网下载安装包:http://www.python.org/ 下载后按步骤安装(最好不要安装到系统盘) 安装好后将安装路径(Python和Scripts) ...

  9. C# List(T).Reverse 方法 顺序反转

    using System; using System.Collections.Generic; public class Example { public static void Main() { L ...

  10. 为什么阿里云服务器的docker启动tomcat这么慢??

    https://blog.csdn.net/tianyiii/article/details/79314597 最近在阿里云服务器使用Docker启动Tomcat,发现tomcat服务器启动过程很慢. ...