当前位置: 首页 > news >正文

Educational Codeforces Round 26

 
Educational Codeforces Round 26
困到不行的场,等着中午显示器到了就可以美滋滋了
A. Text Volume
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a text of single-space separated words, consisting of small and capital Latin letters.

Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.

Calculate the volume of the given text.

Input

The first line contains one integer number n (1 ≤ n ≤ 200) — length of the text.

The second line contains text of single-space separated words s1, s2, ..., si, consisting only of small and capital Latin letters.

Output

Print one integer number — volume of text.

Examples
input
7
NonZERO
output
5
input
24
this is zero answer text
output
0
input
24
Harbour Space University
output
1
Note

In the first example there is only one word, there are 5 capital letters in it.

In the second example all of the words contain 0 capital letters.

求一个单词内最多的大写字母个数,遇到空格处理下,最后也处理下

#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    getchar();
    string s;
    getline(cin,s);
    int sum=0,f=0;
    for(int i=0;s[i];i++){
        if(s[i]==' '){
            if(f>sum)sum=f;
            f=0;
        }else if(s[i]<'a')f++;
    }
    if(f>sum)sum=f;
    cout<<sum<<endl;
    return 0;
}
B. Flag of Berland
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The flag of Berland is such rectangular field n × m that satisfies following conditions:

  • Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
  • Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
  • Each color should be used in exactly one stripe.

You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).

Input

The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.

Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.

Output

Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).

Examples
input
6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG
output
YES
input
4 3
BRG
BRG
BRG
BRG
output
YES
input
6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB
output
NO
input
4 4
RRRR
RRRR
BBBB
GGGG
output
NO
Note

The field in the third example doesn't have three parralel stripes.

Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.

 

 怎样才是波兰的国旗,就是有RGB对吧,那我MAP一下枚举就好了啊

#include<bits/stdc++.h>
using namespace std;
char s[105][105];
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    map<char,int>M;
    M['R']=0,M['B']=0,M['G']=0;
    if(n%3==0){
        for(int i=0;i<n;i+=n/3){
        char c=s[i][0];
        for(int j=i;j<i+n/3;j++)
            for(int k=0;k<m;k++)
             if(c!=s[j][k]) M[c]=-1;
             if(M[c]==0){M[c]=1;}
        }
    }
    if(M['R']==1&&M['G']==1&&M['B']==1)
        return 0*puts("YES");
    M['R']=0,M['B']=0,M['G']=0;
    if(m%3==0){
        for(int i=0;i<m;i+=m/3){
        char c=s[0][i];
        for(int j=i;j<i+m/3;j++)
            for(int k=0;k<n;k++){
             if(c!=s[k][j]) M[c]=-1;}
             if(M[c]==0)M[c]=1;
        }
    }
    if(M['R']==1&&M['G']==1&&M['B']==1)
        return 0*puts("YES");
    puts("NO");
    return 0;
}

 

C. Two Seals
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

One very important person has a piece of paper in the form of a rectangle a × b.

Also, he has n seals. Each seal leaves an impression on the paper in the form of a rectangle of the size xi × yi. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees).

A very important person wants to choose two different seals and put them two impressions. Each of the selected seals puts exactly one impression. Impressions should not overlap (but they can touch sides), and the total area occupied by them should be the largest possible. What is the largest area that can be occupied by two seals?

Input

The first line contains three integer numbers na and b (1 ≤ n, a, b ≤ 100).

Each of the next n lines contain two numbers xiyi (1 ≤ xi, yi ≤ 100).

Output

Print the largest total area that can be occupied by two seals. If you can not select two seals, print 0.

Examples
input
2 2 2
1 2
2 1
output
4
input
4 10 9
2 3
1 1
5 10
9 11
output
56
input
3 10 10
6 6
7 7
20 5
output
0
Note

In the first example you can rotate the second seal by 90 degrees. Then put impression of it right under the impression of the first seal. This will occupy all the piece of paper.

In the second example you can't choose the last seal because it doesn't fit. By choosing the first and the third seals you occupy the largest area.

In the third example there is no such pair of seals that they both can fit on a piece of paper.

 

 C也直接枚举就完事了,枚举左上,再判断另一个合适么?

等换了显示器我就可以换成这种大括号换行了

#include <bits/stdc++.h>
using namespace std;
int N,X,Y,a[105],b[105],f=0;
void la(int x0,int y0,int x1,int y1)
{
    if((x0+x1<=X)&&(y0<=Y)&&(y1<=Y))
    {
        f=max(f,x0*y0+x1*y1);
    }
    if((y0+y1<=Y)&&(x0<=X)&&(x1<=X))
    {
        f=max(f,x0*y0+x1*y1);
    }
}

int main()
{
    cin>>N>>X>>Y;
    for(int i=0; i<N; i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<i; j++)
        {
            la(a[i],b[i],a[j],b[j]);
            la(a[i],b[i],b[j],a[j]);
            la(b[i],a[i],a[j],b[j]);
            la(b[i],a[i],b[j],a[j]);
        }
    }
    cout<<f<<endl;
    return 0;
}

 

E. Vasya's Function
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya is studying number theory. He has denoted a function f(a, b) such that:

  • f(a, 0) = 0;
  • f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b.

Vasya has two numbers x and y, and he wants to calculate f(x, y). He tried to do it by himself, but found out that calculating this function the way he wants to do that might take very long time. So he decided to ask you to implement a program that will calculate this function swiftly.

Input

The first line contains two integer numbers x and y (1 ≤ x, y ≤ 1012).

Output

Print f(x, y).

Examples
input
3 5
output
3
input
6 3
output
1

 

数论的题目,想起来是没有是什么,因为好像和公因数有关,但又不知道有哪些关系还是看大佬代码比较靠谱

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF=1e18;
vector <LL> s;
LL gcd(LL a,LL b)
{
    return b==0?a:gcd(b,a%b);
}
void la(LL x)
{
    LL rx=sqrt(x+0.5);
    if(!(x&1))
    {
        s.push_back(2);
        while(!(x&1)) x/=2;
    }
    for(int i=3; i<=rx; i+=2)
    {
        if(x%i==0)
        {
            s.push_back(i);
            while(x%i==0) x/=i;
        }
    }
    if(x>1) s.push_back(x);
}
int main()
{
    LL x,y;
    scanf("%lld%lld",&x,&y);
    la(x);
    LL ans=0,m;
    while(y)
    {
        LL g=gcd(x,y);
        x/=g;
        y/=g;
        m=y;
        for(auto p:s)
            if(x%p==0)  m=min(m,y%p);
        ans+=m;
        y-=m;
    }
    printf("%lld\n",ans);
    return 0;
}

 

D. Round Subset
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Let's call the roundness of the number the number of zeros to which it ends.

You have an array of n numbers. You need to choose a subset of exactly k numbers so that the roundness of the product of the selected numbers will be maximum possible.

Input

The first line contains two integer numbers n and k (1 ≤ n ≤ 200, 1 ≤ k ≤ n).

The second line contains n space-separated integer numbers a1, a2, ..., an (1 ≤ ai ≤ 1018).

Output

Print maximal roundness of product of the chosen subset of length k.

Examples
input
3 2
50 4 20
output
3
input
5 3
15 16 3 25 9
output
3
input
3 3
9 77 13
output
0
Note

In the first example there are 3 subsets of 2 numbers. [50, 4] has product 200 with roundness 2, [4, 20] — product 80, roundness 1, [50, 20] — product 1000, roundness 3.

In the second example subset [15, 16, 25] has product 6000, roundness 3.

In the third example all subsets has product with roundness 0.

 

k个数的后缀0最多,10的因子是2和5,然后每次取2和5的最小值就好的,dp

#include<bits/stdc++.h>
using namespace std;
#define ll __int64
ll a[250];
int n2[250];
int n5[250];
int dp[2][205][12850];
int la2(ll num)
{
    int sum=0;
    while(num%2==0)num/=2,sum++;
    return sum;
}
int la5(ll num)
{
    int sum=0;
    while(num%5==0)num/=5,sum++;
    return sum;
}
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        memset(dp,-1,sizeof(dp));
        for(int i=1; i<=n; i++)scanf("%I64d",&a[i]);
        for(int i=1; i<=n; i++)
        {
            n2[i]=la2(a[i]);
            n5[i]=la5(a[i]);
        }
        int ma=0;
        dp[0][0][0]=0;
        int f1=0,f2=1;
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
            {
                for(int k=12805; k>=0; k--)
                {
                    dp[f2][j][k]=max(dp[f1][j][k],dp[f1][j][k]);
                    if(k>=n2[i]&&dp[f1][j-1][k-n2[i]]!=-1)
                        dp[f2][j][k]=max(dp[f2][j][k],dp[f1][j-1][k-n2[i]]+n5[i]);
                    ma=max(ma,min(k,dp[f2][j][k]));
                }
            }
            dp[f2][0][0]=dp[f1][0][0];
            swap(f1,f2);
        }
        printf("%d\n",ma);
    }
}

 

 

转载于:https://www.cnblogs.com/BobHuang/p/7283280.html

相关文章:

  • Android 带你撸一个好玩的 DoodleView(涂鸦)
  • javascript中的this和e.target的深入研究
  • 2017-08-04 前端日报
  • 二叉树的最小深度 Minimum Depth of Binary Tree
  • 告别ASP.NET操作EXCEL的烦恼(总结篇)
  • 一个简单RPC框架是怎样炼成的(VI)——引入服务注冊机制
  • UVa 123042D Geometry 110 in 1! [平面几何]
  • 【实用代码片段】将json数据绑定到html元素 (转)
  • HNUSTOJ 1516:Loky的烦恼
  • MySQL运维命令大全
  • 蓝盾股份增资参股云海麒麟 布局国产云计算业务
  • 2017年十大技术发展趋势概述
  • wxWidgets第十课 渲染字体
  • Centos x64 6.9下载地址
  • 十二个 ASP.NET Core 例子——1.1版本 EF MySql快速搭建
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • 【跃迁之路】【463天】刻意练习系列222(2018.05.14)
  • JavaScript 事件——“事件类型”中“HTML5事件”的注意要点
  • java概述
  • LeetCode刷题——29. Divide Two Integers(Part 1靠自己)
  • magento 货币换算
  • MySQL用户中的%到底包不包括localhost?
  • node 版本过低
  • Spring Boot MyBatis配置多种数据库
  • supervisor 永不挂掉的进程 安装以及使用
  • Theano - 导数
  • 对象管理器(defineProperty)学习笔记
  • 工作手记之html2canvas使用概述
  • 记录:CentOS7.2配置LNMP环境记录
  • 验证码识别技术——15分钟带你突破各种复杂不定长验证码
  • 终端用户监控:真实用户监控还是模拟监控?
  • ## 临床数据 两两比较 加显著性boxplot加显著性
  • #QT(TCP网络编程-服务端)
  • #我与Java虚拟机的故事#连载02:“小蓝”陪伴的日日夜夜
  • $con= MySQL有关填空题_2015年计算机二级考试《MySQL》提高练习题(10)
  • (16)UiBot:智能化软件机器人(以头歌抓取课程数据为例)
  • (bean配置类的注解开发)学习Spring的第十三天
  • (solr系列:一)使用tomcat部署solr服务
  • (附源码)ssm捐赠救助系统 毕业设计 060945
  • (更新)A股上市公司华证ESG评级得分稳健性校验ESG得分年均值中位数(2009-2023年.12)
  • (七)MySQL是如何将LRU链表的使用性能优化到极致的?
  • (三)Hyperledger Fabric 1.1安装部署-chaincode测试
  • (四)图像的%2线性拉伸
  • (原创)boost.property_tree解析xml的帮助类以及中文解析问题的解决
  • (源码版)2024美国大学生数学建模E题财产保险的可持续模型详解思路+具体代码季节性时序预测SARIMA天气预测建模
  • ***原理与防范
  • .java 9 找不到符号_java找不到符号
  • .NET 4.0中使用内存映射文件实现进程通讯
  • .NET Core 2.1路线图
  • .NET 将混合了多个不同平台(Windows Mac Linux)的文件 目录的路径格式化成同一个平台下的路径
  • .NET/C# 解压 Zip 文件时出现异常:System.IO.InvalidDataException: 找不到中央目录结尾记录。
  • .net中我喜欢的两种验证码
  • @Autowired注解的实现原理
  • @ComponentScan比较
  • @Transactional类内部访问失效原因详解