A. Phone Numbers

题意:给一些数字,每个电话号码以8开头,11位,求最多组成多少个号码,重复累加。

#include <bits/stdc++.h>

using namespace std;

const int maxn = ;
char str[maxn]; int main() {
int n;
scanf("%d%s",&n,str);
int cnt = ;
for(int i = ; i < strlen(str); i++) {
if(str[i]=='') cnt++;
} while(cnt) {
if((n-cnt)>=cnt*) break;
cnt--;
} cout<<cnt<<endl; return ;
}

B. Maximum Sum of Digits

题意:给一个数n,找出 a,b,使得 a + b = n,S(a) + S(b) 最大,其中S(x) 是个位数字之和。

分析:从案例中可知,先尽可能出9

#include <bits/stdc++.h>

using namespace std;

char str[];

int calc(long long x) {
int res = ;
while(x) {
res += x%;
x/=;
}
return res;
} int main() {
scanf("%s",str);
long long x= ;
for(int i = ; i < (int)strlen(str); i++)
x = x* + str[i] - ''; long long a;
if(str[]>'') {
a = (str[]-'')-;
for(int i = ; i < (int)strlen(str); i++) {
a = a * + ;
}
}
else {
a = ;
for(int i = ; i < (int)strlen(str); i++) {
a = a * + ;
}
} long long b = x - a;
printf("%d\n",calc(a)+calc(b)); return ;
}

C. Maximum Subrectangle

分析:最大子矩阵,矩阵是由两个向量计算而成,子矩阵和=两个向量部分乘积。计算a,b向量,连续 i 个数字最小和,这样组成的子矩阵和最小,然后枚举子矩阵长宽。

#include <bits/stdc++.h>

using namespace std;

const int maxn = +;
int a[maxn],b[maxn],min1[maxn],min2[maxn]; int main() { int n,m;
scanf("%d%d",&n,&m); for(int i = ; i <= n; i++) scanf("%d",&a[i]);
for(int i = ; i <= m; i++) scanf("%d",&b[i]);
int x; scanf("%d",&x); for(int i = ; i <= n; i++) {
int sum = ;
for(int j = ; j <= i; j++) sum+=a[j];
min1[i] = sum;
for(int j = i+; j <= n; j++) {
sum-=a[j-i];
sum+=a[j];
min1[i] = min(min1[i],sum);
}
} for(int i = ; i <= m; i++) {
int sum = ;
for(int j = ; j <= i; j++) sum+=b[j];
min2[i] = sum;
for(int j = i+; j <= m; j++) {
sum-=b[j-i];
sum+=b[j];
min2[i] = min(min2[i],sum);
}
} int ans = ;
for(int i = ; i<= n; i++) {
for(int j = ; j <= m; j++) {
if((long long)min1[i]*min2[j]<=x)
ans = max(ans,i*j);
}
} cout<<ans<<endl; return ;
}

Codeforces Round #513的更多相关文章

  1. Codeforces Round #513 游记

    Codeforces Round #513 游记 A - Phone Numbers 题目大意: 电话号码是8开头的\(1\)位数字.告诉你\(n(n\le100)\)个数字,每个数字至多使用一次.问 ...

  2. Codeforces Round #513 总结

    首次正式的$Codeforces$比赛啊,虽然滚粗了,然而终于有$rating$了…… #A  Phone Numbers 签到题,然而我第一次写挂了(因为把11看成8了……) 只需要判断一下有多少个 ...

  3. Codeforces Round #513 by Barcelona Bootcamp C. Maximum Subrectangle(双指针+思维)

    https://codeforces.com/contest/1060/problem/C 题意 给两个数组,a数组有n个元素,b数组有m个元素,两个数组元素互相相乘形成n*m的矩阵,找一个子矩阵,元 ...

  4. Codeforces Round #513解题报告(A~E)By cellur925

    我是比赛地址 A:Phone Numbers $Description$:给你一串数字,问你能组成多少开头为8的11位电话号码. $Sol$:统计8的数量,与$n$%11作比较. #include&l ...

  5. Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) C D

    C - Maximum Subrectangle 因为是两个数组相乘的到的 矩阵所以  a(i ->j)*b(x->y) 的面积 就是   a(i ->j) 的和乘与b(x-> ...

  6. Codeforces Round #513 by Barcelona Bootcamp

    A. Phone Numbers 签. #include <bits/stdc++.h> using namespace std; #define N 110 char s[N]; ], ...

  7. [Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) ](A~E)

    A: 题目大意:给你一个数字串,每个数字只可以用一次,求最多可以组成多少个电话号码(可以相同),电话号码第一个数字为$8$,且长度为$11$ 题解:限制为$8$的个数和总长度,直接求 卡点:无 C++ ...

  8. Codeforces Round 513 (Div.1+Div.2)

    比赛传送门 10月4号的比赛,因为各种原因(主要是懒),今天才写总结-- Div1+Div2,只做出两个题+迟到\(20min\),日常掉\(rating\)-- \(\rm{A.Phone\;Num ...

  9. Codeforces Round #513 (rated, Div. 1 + Div. 2)

    前记 眼看他起高楼:眼看他宴宾客:眼看他楼坍了. 比赛历程 开考前一分钟还在慌里慌张地订正上午考试题目. “诶这个数位dp哪里见了鬼了???”瞥了眼时间,无奈而迅速地关去所有其他窗口,临时打了一个缺省 ...

随机推荐

  1. js数组方法详解

    Array对象的方法-25个 /*js数组方法详解 */ /* * 1 concat() 用于连接多个数组或者值-------------- * 2 copyWithin() 方法用于从数组的指定位置 ...

  2. 邮件email

    参考地址:https://blog.csdn.net/baidu_30000217/article/details/52942258 邮箱配置地址:http://service.exmail.qq.c ...

  3. HDU 4460 Friend Chains

    Problem Description For a group of people, there is an idea that everyone is equals to or less than ...

  4. c#输入方法名来调用方法(反射)

    using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Sy ...

  5. 小型Basic编译器问题

    # include <stdio.h> # include <string.h> # include <ctype.h> # include <stdlib. ...

  6. java url生成二维码保存到本地

    http://blog.sina.com.cn/s/blog_5a6efa330102v1lb.html http://blog.csdn.net/about58238/article/details ...

  7. 修改Linux时区的2种办法

    由于Azure 上所有的服务时间都采用了 UTC 时间.UTC 时间比中国时间晚 8 个小时,该如何按照自己的需要来进行修改呢,下面提供2种办法以供参考: 1.修改 /etc/localtime 文件 ...

  8. C#程序执行时间

    Stopwatch类 using System.Diagnostics; static void Main(string[] args) { Stopwatch stopWatch = new Sto ...

  9. python-requests 简单实现数据抓取

    安装包: requests,lxmlrequest包用于进行数据抓取,lxml用来进行数据解析对于对网页内容的处理,由于html本身并非如数据库一样为结构化的查询所见即所得,所以需要对网页的内容进行分 ...

  10. hdu 1513 添最少字回文 (Lcs 滚动数组)

    http://blog.csdn.net/ice_crazy/article/details/8244639 这里5000*5000超出内存,所以需要用滚动数组: 用一个now表示当前的结果,pre表 ...