今日竞赛—解题报告

B - B

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status Practice CodeForces 554B

Description

Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a clean square, it will become dirty, and if she sweeps over a dirty square, it will become clean. She wants to sweep some columns of the room to maximize the number of rows that are completely clean. It is not allowed to sweep over the part of the column, Ohana can only sweep the whole column.

Return the maximum number of rows that she can make completely clean.

Input

The first line of input will be a single integer n (1 ≤ n ≤ 100).

The next n lines will describe the state of the room. The i-th line will contain a binary string with n characters denoting the state of the i-th row of the room. The j-th character on this line is ‘1‘ if the j-th square in the i-th row is clean, and ‘0‘ if it is dirty.

Output

The output should be a single line containing an integer equal to a maximum possible number of rows that are completely clean.

Sample Input

Input

40101100011110101

Output

2

Input

3111111111

Output

3

Hint

In the first sample, Ohana can sweep the 1st and 3rd columns. This will make the 1st and 4th row be completely clean.

In the second sample, everything is already clean, so Ohana doesn‘t need to do anything.

解题思路:本题主要思路在于计算有多少行相等,并输出相等最多行数

代码

#include <iostream>
#include <string.h>
#include <cstdio>

using namespace std;
string a[100];
int b[100];
int main()
{
int n,i=0,m=0;
memset(b,0,sizeof(b));
cin>>n;int j=n;
while(n--)
{
    cin>>a[i];
    for(int j=i;j>=0;j--)
if(a[j]==a[i])   b[i]++;
if(b[i]>m)  m=b[i];
i++;
}
cout<<m<<endl;

    return 0;
}

C - C

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status Practice CodeForces 492A

Description

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyramid must have 1 + 2 + ... + (i - 1) + i cubes.

Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.

Input

The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.

Output

Print the maximum possible height of the pyramid in the single line.

Sample Input

Input

1

Output

1

Input

25

Output

4

Hint

Illustration to the second sample:

解题思路:本题主要思路是累加思想,第N行的数就要从1+2+....+N,所以一个N行高的金字塔总和即是1+(1+2)+(1+2+3)+.....+(1+2+3+..+N)
代码:#include <iostream>
using namespace std;
int main()
{
    int n,t;
    cin>>n;
    int i,sum=0,j=1;
    while(sum<=n)
    {   t=0;
        for(i=1;i<=j;i++)
        t+=i;
        sum+=t;j++;
    }
    cout<<j-2<<endl;
    return 0;
}

F - F

Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu

Submit Status Practice CSU 1337

Description

费马大定理:当n>2时,不定方程an+bn=cn没有正整数解。比如a3+b3=c3没有正整数解。为了活跃气氛,我们不妨来个搞笑版:把方程改成a3+b3=c3,这样就有解了,比如a=4, b=9, c=79时43+93=793。

输入两个整数x, y, 求满足x<=a,b,c<=y的整数解的个数。

Input

输入最多包含10组数据。每组数据包含两个整数x, y(1<=x,y<=108)。

Output

对于每组数据,输出解的个数。

Sample Input

1 10
1 20
123 456789 

Sample Output

Case 1: 0
Case 2: 2
Case 3: 16 

解题思路:

虽然x和y的范围都是10^8,但是如果a 是大于1000的话,那么a^3就会大于10^9,这样等号的右边只有一个10 * c + 3,这个最大只能达到10^9数量级,所以,不管输入的x跟y是多少,我们只要取其中的在1到1000的区间就可以了,枚举a和b,那么c就可以得到,然 后判断c的范围是不是在x到y之间,这样时间复杂度就降到了10^6.

有了上面的分析,这道题就很简单啦;程序代码:#include <iostream>#include <cstdio>using namespace std;

int a,b,c,d,x,y,i=0;int main(){       while(cin>>x>>y)    {  int m=0;    for(a=x;a<=y&&a<=1000;a++)            for(b=x;b<=y&&b<=1000;b++)        {            c=a*a*a+b*b*b;            if(c%10==3)            {   d=(c-3)/10;                if(d>=x&&d<=y)  m++;            }

        }        cout<<"Case "<<++i<<": "<<m<<endl;    }    return 0;}
时间: 2024-10-12 17:39:37

今日竞赛—解题报告的相关文章

今日竞赛——解题报告

MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 546A Description A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in

2014年山东省第五届ACM大学生程序设计竞赛解题报告

A  angry_birds_again_and_again http://www.sdutacm.org/sdutoj/problem.php?action=showproblem&problemid=2877 数学题,求抛物线和直线围成的面积,用积分来做. 设方程 y=ax^2+bx+c ,图中曲线经过原点,所以c=0. 对方程求导 y'=2ax+b ,  y'代表斜率,那么原点(0,0)这一点,代人y'=b,即该点的斜率,根据题意b=tan( α) 如图:在题目中x=tx这一点时,容易混,

解题报告:LeetCode The Skyline Problem(画天际

题目出处:https://leetcode.com/submissions/detail/47013144/题意描述: 给定一系列矩形的左边坐标Li,右边坐标Ri,和高度Hi(其中Li按照从小到大的顺序排列).代表城市中一座座高楼.求这些矩形代表的高楼行成的天际线.天际线的定义为:在远处看这些所有的高楼时看到的轮廓. 数据输入: [ [L1, R1, H1], [Li, Ri, Hi]...]为元素类型为三维向量的向量,其中Li,Ri,Hi的含义见题意描述.且输入数据保证: 0 ≤ Li, Ri

2014 UESTC暑前集训数据结构专题解题报告

A.Islands 这种联通块的问题一看就知道是并查集的思想. 做法:从高水位到低水位依序进行操作,这样每次都有新的块浮出水面,可以在前面的基础上进行合并集合的操作.给每个位置分配一个数字,方便合并集合.同时将这些数字也排一个序,降低枚举的复杂度.合并集合时向四周查询浮出水面但是没有合并到同一集合的点进行合并. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath&

Best Cow Line 解题报告

题目链接: http://poj.org/problem?id=3617 题意: 已知一段长度为N的字符串,让你构造一个字典序最小的字符串.构造的规则如下:如果原始字符串的头部 < 原始字符串的尾部,则从原始字符串的头部删除该字符添加到新         的字符串的一个字符;如果头部 > 尾部则删除尾部的字符添加到新字符串中. 解题思路: 首先用两个索引记录首尾的位置,然后依次比较两者的值,若头部的值小则头部索引+1向后移动一位,若尾部的值小则尾部索引-1向前移动一位,这是当两个位置的值不一样

2020-3-14 acm训练联盟周赛Preliminaries for Benelux Algorithm Programming Contest 2019 解题报告+补题报告

2020-3-15比赛解题报告+2020-3-8—2020-3-15的补题报告 2020-3-15比赛题解 训练联盟周赛Preliminaries for Benelux Algorithm Programming Contest 2019  A建筑(模拟) 耗时:3ms 244KB 建筑 你哥哥在最近的建筑问题突破大会上获得了一个奖项 并获得了千载难逢的重新设计城市中心的机会 他最喜欢的城市奈梅根.由于城市布局中最引人注目的部分是天际线, 你的兄弟已经开始为他想要北方和东方的天际线画一些想法

解题报告 之 POJ3057 Evacuation

解题报告 之 POJ3057 Evacuation Description Fires can be disastrous, especially when a fire breaks out in a room that is completely filled with people. Rooms usually have a couple of exits and emergency exits, but with everyone rushing out at the same time

hdu 1541 Stars 解题报告

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1541 题目意思:有 N 颗星星,每颗星星都有各自的等级.给出每颗星星的坐标(x, y),它的等级由所有比它低层(或者同层)的或者在它左手边的星星数决定.计算出每个等级(0 ~ n-1)的星星各有多少颗. 我只能说,题目换了一下就不会变通了,泪~~~~ 星星的分布是不是很像树状数组呢~~~没错,就是树状数组题来滴! 按照题目输入,当前星星与后面的星星没有关系.所以只要把 x 之前的横坐标加起来就可以了

【百度之星2014~初赛(第二轮)解题报告】Chess

声明 笔者最近意外的发现 笔者的个人网站http://tiankonguse.com/ 的很多文章被其它网站转载,但是转载时未声明文章来源或参考自 http://tiankonguse.com/ 网站,因此,笔者添加此条声明. 郑重声明:这篇记录<[百度之星2014~初赛(第二轮)解题报告]Chess>转载自 http://tiankonguse.com/ 的这条记录:http://tiankonguse.com/record/record.php?id=667 前言 最近要毕业了,有半年没做