Codeforces Round #513
题意:给一些数字,每个电话号码以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 ;
}
题意:给一个数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 ;
}
分析:最大子矩阵,矩阵是由两个向量计算而成,子矩阵和=两个向量部分乘积。计算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的更多相关文章
- Codeforces Round #513 游记
Codeforces Round #513 游记 A - Phone Numbers 题目大意: 电话号码是8开头的\(1\)位数字.告诉你\(n(n\le100)\)个数字,每个数字至多使用一次.问 ...
- Codeforces Round #513 总结
首次正式的$Codeforces$比赛啊,虽然滚粗了,然而终于有$rating$了…… #A Phone Numbers 签到题,然而我第一次写挂了(因为把11看成8了……) 只需要判断一下有多少个 ...
- Codeforces Round #513 by Barcelona Bootcamp C. Maximum Subrectangle(双指针+思维)
https://codeforces.com/contest/1060/problem/C 题意 给两个数组,a数组有n个元素,b数组有m个元素,两个数组元素互相相乘形成n*m的矩阵,找一个子矩阵,元 ...
- Codeforces Round #513解题报告(A~E)By cellur925
我是比赛地址 A:Phone Numbers $Description$:给你一串数字,问你能组成多少开头为8的11位电话号码. $Sol$:统计8的数量,与$n$%11作比较. #include&l ...
- 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-> ...
- Codeforces Round #513 by Barcelona Bootcamp
A. Phone Numbers 签. #include <bits/stdc++.h> using namespace std; #define N 110 char s[N]; ], ...
- [Codeforces Round #513 by Barcelona Bootcamp (rated, Div. 1 + Div. 2) ](A~E)
A: 题目大意:给你一个数字串,每个数字只可以用一次,求最多可以组成多少个电话号码(可以相同),电话号码第一个数字为$8$,且长度为$11$ 题解:限制为$8$的个数和总长度,直接求 卡点:无 C++ ...
- Codeforces Round 513 (Div.1+Div.2)
比赛传送门 10月4号的比赛,因为各种原因(主要是懒),今天才写总结-- Div1+Div2,只做出两个题+迟到\(20min\),日常掉\(rating\)-- \(\rm{A.Phone\;Num ...
- Codeforces Round #513 (rated, Div. 1 + Div. 2)
前记 眼看他起高楼:眼看他宴宾客:眼看他楼坍了. 比赛历程 开考前一分钟还在慌里慌张地订正上午考试题目. “诶这个数位dp哪里见了鬼了???”瞥了眼时间,无奈而迅速地关去所有其他窗口,临时打了一个缺省 ...
随机推荐
- vue filters过滤器的使用
说的很详细 https://www.w3cplus.com/vue/how-to-create-filters-in-vuejs.html
- logrtate 切割详解
Logrotate是Linux下一款日志管理工具,可用于日志文件的转储(即删除旧日志文件,创建新日志文件).可以根据日志大小或者按照某时段间隔来转储,内部使用cron程序来执行.Logrotate还可 ...
- Html练习 | 小影志首页练习
<!DOCTYPE html> <head> <title>小影志首页练习</title> <style> /*应用全页字体*/ .pg-f ...
- TOJ 4523 Transportation
Description Given N stations, you want to carry goods from station 1 to station N. Among these stati ...
- 数组和json的相互转换
json_encode() <?php /*****一维数组*********/ //有键 $arr = array( 'a'=>1, 'b'=>2, 'c'=>3, ); $ ...
- React.js 小书 Lesson16 - 实战分析:评论功能(三)
作者:胡子大哈 原文链接:http://huziketang.com/books/react/lesson16 转载请注明出处,保留原文链接和作者信息. 接下来的代码比较顺理成章了.修改 Commen ...
- [转]什么?你还不会写JQuery 插件
本文转自:http://www.cnblogs.com/joey0210/p/3408349.html 前言 如今做web开发,jquery 几乎是必不可少的,就连vs神器在2010版本开始将Jque ...
- 重构指南 - 尽快返回(Return ASAP )
尽快返回就是如果方法中的条件判断可以得到结果,则尽快返回该结果. 1. 检查条件,如果不满足就立即返回,不执行下面的逻辑. 2. 当包含大量的if else嵌套,代码可读性变差,也容易出现异常. 3. ...
- 【Android】9.0活动的生命周期(二)——实际代码演示
1.0 新建一个项目ActivityLifeCycleTest. 新建两个活动NormalActivity和DialogActivity,勾选“Generate Layout File”. 文件目录 ...
- arcgis server 10.1 发布动态图层展示海量及频繁更新的数据步骤
Arcgis server 发布动态图层及调用动态图层 做这个动态图层功能的原由是 有一个30万的数据需要通过arcgis GP工具转成shp然后渲染加载进地图,原来的做法是遍历生成shp面要素,读 ...