2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 |
---|
A题:http://codeforces.com/gym/101028/problem/A
题意:比赛初始值是1500,变化了几次,得到的正确结果和bug后的是否相等。(Tourist大佬好 Y(^o^)Y)
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--) {
- int n,r;
- cin>>n>>r;
- int sum = ;
- for(int i=;i<n;i++)
- {
- int x;
- cin>>x;
- sum+=x;
- }
- if(sum==r)
- puts("Correct");
- else puts("Bug");
- }
- return ;
- }
A. Codeforces Rating
B题:http://codeforces.com/gym/101028/problem/B
题意:b,p不分,i,e不分,大小写不分,看两个字符串是不是正确的。
- #include <bits/stdc++.h>
- using namespace std;
- char str1[],str2[];
- int main()
- {
- int t;
- cin>>t;
- while(t--) {
- scanf("%s%s",str1,str2);
- int len = strlen(str1);
- if(strlen(str1)!=strlen(str2)) {
- puts("No");
- continue;
- }
- for(int i=;i<len;i++)
- {
- if(str1[i]>='A'&&str1[i]<='Z')
- str1[i] = 'a' + str1[i] - 'A';
- if(str2[i]>='A'&&str2[i]<='Z')
- str2[i] = 'a' + str2[i] - 'A';
- }
- bool flag = true;
- for(int i=;i<len;i++) {
- if(str1[i]!=str2[i]) {
- if(str1[i]=='b'&&str2[i]=='p')
- continue;
- if(str1[i]=='p'&&str2[i]=='b')
- continue;
- if(str1[i]=='i'&&str2[i]=='e')
- continue;
- if(str1[i]=='e'&&str2[i]=='i')
- continue;
- flag = false;
- break;
- }
- }
- if(flag)
- puts("Yes");
- else puts("No");
- }
- return ;
- }
B. Bonapity
C题:http://codeforces.com/gym/101028/problem/C
题意:已知A,B,求C有多少种情况满足这个式子:
比赛的时候,很多同学没有看到取模,用java干;
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--) {
- int len;
- cin>>len;
- int a[],b[];
- char stra[],strb[];
- scanf("%s%s",stra,strb);
- for(int i=;i<len;i++)
- {
- a[i] = stra[i]-'';
- b[i] = strb[i]-'';
- }
- unsigned long long ans = ;
- bool flag = true;
- for(int i=;i<len;i++) {
- if(a[i]==&&b[i]==)
- continue;
- if(a[i]==&&b[i]==)
- continue;
- if(a[i]==&&b[i]==){
- flag = false;
- break;
- }
- if(a[i]==&&b[i]==)
- ans = ans*%;
- }
- if(flag)
- cout<<ans<<endl;
- else puts("IMPOSSIBLE");
- }
- return ;
- }
C. A or B Equals C
D题:http://codeforces.com/gym/101028/problem/D
题意:画图
- #include <bits/stdc++.h>
- using namespace std;
- char maps[][];
- int main()
- {
- int t;
- scanf("%d",&t);
- while(t--)
- {
- memset(maps,'.',sizeof(maps));
- int r,c,n;
- cin>>r>>c>>n;
- while(n--)
- {
- int r1, c1, r2, c2;
- char x;
- cin>>r1>>c1>>r2>>c2>>x;
- for(int i=r1; i<=r2; i++)
- {
- for(int j=c1; j<=c2; j++)
- {
- maps[i][j] = x;
- }
- }
- }
- for(int i=; i<=r; i++)
- {
- for(int j=; j<=c; j++)
- printf("%c",maps[i][j]);
- puts("");
- }
- }
- return ;
- }
D. X and paintings
E题:http://codeforces.com/gym/101028/problem/E
题意:n个数的最大公约数
- #include <bits/stdc++.h>
- using namespace std;
- const int inf = 0x3f3f3f3f;
- int main()
- {
- int t;
- int a[];
- scanf("%d",&t);
- while(t--) {
- int minx = inf;
- int n;
- scanf("%d",&n);
- for(int i=;i<n;i++) {
- scanf("%d",&a[i]);
- minx = min(minx,a[i]);
- }
- int k;
- for(k=minx;k>=;k--) {
- bool flag = true;
- for(int i=;i<n;i++) {
- if(a[i]%k!=) {
- flag = false;
- break;
- }
- }
- if(flag)
- break;
- }
- int num = ;
- for(int i=;i<n;i++)
- num+=(a[i]/k);
- printf("%d %d\n",k,num);
- }
- return ;
- }
E. Teams
F题:http://codeforces.com/gym/101028/problem/F
题意:字符串匹配(朴素匹配就ok了)
- #include <bits/stdc++.h>
- using namespace std;
- char str1[],str2[];
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- scanf("%s%s",str1,str2);
- int len = strlen(str1);
- char op[][];
- memset(op,,sizeof(op));
- for(int i=; i<; i++)
- {
- int k=;
- for(int j=; j<; j++)
- {
- if(i!=j)
- op[i][k++] = str2[j];
- }
- }
- // for(int i=0;i<4;i++) {
- // for(int j=0;j<3;j++)
- // printf("%c",op[i][j]);
- // puts("");
- // }
- bool good = false;
- for(int i=; i<len-; i++)
- {
- if(str1[i]==str2[]&&str1[i+]==str2[]&&str1[i+]==str2[]&&str1[i+]==str2[])
- {
- good = true;
- break;
- }
- }
- if(good)
- {
- puts("good");
- continue;
- }
- bool al = false;
- for(int i=; i<len-; i++)
- {
- if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
- {
- al = true;
- break;
- }
- }
- if(al)
- {
- puts("almost good");
- continue;
- }
- al = false;
- for(int i=; i<len-; i++)
- {
- if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
- {
- al = true;
- break;
- }
- }
- if(al)
- {
- puts("almost good");
- continue;
- }
- al = false;
- for(int i=; i<len-; i++)
- {
- if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
- {
- al = true;
- break;
- }
- }
- if(al)
- {
- puts("almost good");
- continue;
- }
- al = false;
- for(int i=; i<len-; i++)
- {
- if(str1[i]==op[][]&&str1[i+]==op[][]&&str1[i+]==op[][])
- {
- al = true;
- break;
- }
- }
- if(al)
- {
- puts("almost good");
- continue;
- }
- puts("none");
- }
- return ;
- }
F. Good Words
G题:http://codeforces.com/gym/101028/problem/G
题意:从左上角砸东西到目的地,途中碰壁。看可以不可以砸到目标。和省赛的球的碰撞类似。
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--) {
- int h,w,d;
- cin>>h>>w>>d;
- int x = (h-)/(w-); //x个单周期
- int mod = (h-)%(w-);
- int md;
- if(x%==)
- md = + mod;
- else md = w - mod ;
- if(md==d)
- puts("Yes");
- else puts("No");
- }
- return ;
- }
G. The Tower of Evil
H题:http://codeforces.com/gym/101028/problem/H
做到这里的时候,脑子已经晕掉了,题目也没怎么看清楚。
题意:n长的河流,两个人的速度是d,r,在start的位置不标记,求第一次踩到对方标记的时间。
- #include <bits/stdc++.h>
- using namespace std;
- int v1[];
- int v2[];
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- memset(v1,,sizeof(v1));
- memset(v2,,sizeof(v2));
- int n,d,r;
- cin>>n>>d>>r;
- int ans = ;
- int td = d;
- int tr = r;
- v1[td] = ;
- v2[tr] = ;
- while(true)
- {
- if(v2[td]==true||v1[tr]==true)
- {
- break;
- }
- ans++;
- td = (td + d)%n;
- tr = (tr + r)%n;
- v1[td] = true;
- v2[tr] = true;
- }
- printf("%d\n",ans);
- }
- return ;
- }
H. The Endless River
I题:http://codeforces.com/gym/101028/problem/I
题意:屋顶有漏洞,用k个布去补洞,其中最长的布,使其最短。
二分啊!
- #include <bits/stdc++.h>
- using namespace std;
- int a[];
- int n,k;
- int maxx;
- bool calc(int x) {
- int cur = ;
- for(int i=;i<k;i++) {
- if(cur==)
- cur = cur + a[] + x -;
- else {
- for(int i=;i<n;i++) {
- if(a[i]>cur)
- {
- cur = a[i];
- break;
- }
- }
- cur = cur + x -;
- }
- }
- if(cur>=a[n-])
- return true;
- return false;
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--) {
- cin>>n>>k;
- for(int i=;i<n;i++)
- scanf("%d",&a[i]);
- maxx = a[n-];
- int l=;
- int r=a[n-]/k+;
- while(l<r) {
- int m = (r+l)/;
- if(calc(m))
- r=m;
- else l = m+;
- }
- printf("%d\n",l);
- }
- return ;
- }
I. March Rain
J题:http://codeforces.com/gym/101028/problem/J
题意:
一个数列a,他的最大的2i 的因子,由 i 组成的一个数列。
找一些a,他是递增的基础上,i 之和最大。
dp啊!
- #include <bits/stdc++.h>
- using namespace std;
- int a[];
- int as[];
- int b[];
- int dp[];
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- memset(b,,sizeof(b));
- memset(dp,,sizeof(dp));
- int n;
- cin>>n;
- for(int i=; i<n; i++) {
- cin>>a[i];
- as[i] = a[i];
- }
- for(int i=; i<n; i++)
- {
- while(as[i]%==)
- {
- b[i]++;
- as[i] /=;
- }
- }
- dp[] = b[];
- for(int i=; i<n; i++)
- {
- int k = ;
- for(int j=; j<i; j++)
- {
- if(a[j]<a[i]&&k<dp[j])
- {
- k = dp[j];
- }
- }
- dp[i] = k+b[i];
- }
- int ans = -;
- for(int i=; i<n; i++)
- {
- ans = max(ans,dp[i]);
- }
- cout<<ans<<endl;
- }
- return ;
- }
J. X and Beasts
最后贴一下Rank.
2016 Al-Baath University Training Camp Contest-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 ...
- 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 ...
- 2016 Al-Baath University Training Camp Contest-1 B
Description A group of junior programmers are attending an advanced programming camp, where they lea ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 签名:实现参数字典排序,然后拼接为url参数形式
在很多地方请求参数需要做处理例如: 步骤 1.参数字典排序. 2.拼接字符. /// <summary> /// 生成签名 /// </summary> /// <par ...
- RequestContextHolder与RequestContextUtils
org.springframework.web.servlet.support.RequestContextUtils 在spring-webmvc中, 主要用来获取WebApplicationCon ...
- 1 Groovy
1.1 什么是Groovy? groovy 是一个弱类型,动态语言,并且运行在JVM之上.它与java联系紧密.它是一个功能丰富和友好的java语言. Groovy源代码,通过Groovy编译器编译 ...
- 练习五十六:for循环
某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换 方法一: def o ...
- Python学习笔记_零碎知识
1. 变量本身类型不固定的语言称之为动态语言,与之对应的是静态语言.静态语言在定义变量时必须指定变量类型,如果赋值的时候类型不匹配,就会报错. 2. Python有两种除法: /除法计算结果是浮点数, ...
- vue自定义指令拖动div
钩子函数一个指令定义对象可以提供如下几个钩子函数:bind:只掉用一次,指令第一次绑定到元素是调用,在这里可以进行一次性的初始化设置inserted:被绑定元素插入父节点时调用(仅保证父节点存在,但不 ...
- android 闹钟设置问题
Android开发中,alarmManager在5.0以上系统,启动时间设置无效的问题 做一个app,需要后台保持发送心跳包.由于锁屏后CPU休眠,导致心跳包线程被挂起,所以尝试使用alarmMana ...
- 安装Python + Selenium
1.Python下载与安装 先去Python官网下载安装包:http://www.python.org/ 下载后按步骤安装(最好不要安装到系统盘) 安装好后将安装路径(Python和Scripts) ...
- C# List(T).Reverse 方法 顺序反转
using System; using System.Collections.Generic; public class Example { public static void Main() { L ...
- 为什么阿里云服务器的docker启动tomcat这么慢??
https://blog.csdn.net/tianyiii/article/details/79314597 最近在阿里云服务器使用Docker启动Tomcat,发现tomcat服务器启动过程很慢. ...