博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #420 (Div. 2)
阅读量:5957 次
发布时间:2019-06-19

本文共 3924 字,大约阅读时间需要 13 分钟。

这一场PP说很简单,我就闲来无事敲一敲好了,反正也考完了(雾,不过只剩数据结构和c++
A. Okabe and Future Gadget Laboratory
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by nsquare grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 ≤ x, y ≤ n and ax, y ≠ 1, there should exist two indices s and t so that ax, y = ax, s + at, y, where ai, j denotes the integer in i-th row and j-th column.

Help Okabe determine whether a given lab is good!

Input

The first line of input contains the integer n (1 ≤ n ≤ 50) — the size of the lab.

The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is ai, j (1 ≤ ai, j ≤ 105).

Output

Print "Yes" if the given lab is good and "No" otherwise.

You can output each letter in upper or lower case.

Examples
input
3 1 1 2 2 3 1 6 4 1
output
Yes
input
3 1 5 2 1 1 1 1 2 3
output
No
Note

In the first sample test, the 6 in the bottom left corner is valid because it is the sum of the 2 above it and the 4 on the right. The same holds for every number not equal to 1 in this table, so the answer is "Yes".

In the second sample test, the 5 cannot be formed as the sum of an integer in the same row and an integer in the same column. Thus the answer is "No".

 这个题的意思就是给你一个矩阵,假如不是1的话让你找一个所在行的数和所在列的数是不是和他想等,正确yes,否则no。暴力就可以的

#include 
int a[55][55];int n;int solve(int x,int y) { for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) if(a[x][i]+a[j][y]==a[x][y]) return 1; return 0;}int main() { scanf("%d",&n); for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) scanf("%d",a[i]+j); for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) if(a[i][j]!=1) if(solve(i,j)==0) return 0*printf("No"); return 0*printf("Yes");}

 

 

B. Okabe and Banana Trees
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.

Consider the point (x, y) in the 2D plane such that x and y are integers and 0 ≤ x, y. There is a tree in such a point, and it has x + ybananas. There are no trees nor bananas in other points. Now, Okabe draws a line with equation . Okabe can select a single rectangle with axis aligned sides with all points on or under the line and cut all the trees in all points that are inside or on the border of this rectangle and take their bananas. Okabe's rectangle can be degenerate; that is, it can be a line segment or even a point.

Help Okabe and find the maximum number of bananas he can get if he chooses the rectangle wisely.

Okabe is sure that the answer does not exceed 1018. You can trust him.

Input

The first line of input contains two space-separated integers m and b (1 ≤ m ≤ 1000, 1 ≤ b ≤ 10000).

Output

Print the maximum number of bananas Okabe can get from the trees he cuts.

Examples
input
1 5
output
30
input
2 3
output
25
Note

The graph above corresponds to sample test 1. The optimal rectangle is shown in red and has 30 bananas.

 给你一条经过1,3,4象限的直线,让我找到一个矩形价值最大的值,一个矩形的价值是这个矩形中所有的点X和Y的加和,这是个等差数列的和

直接暴力枚举好了

#include 
#include
using namespace std;typedef long long LL;int main() { int m,b; scanf("%d%d",&m,&b); LL ma=0; for(int y=0; y<=b; y++) { LL x=(b-y)*m; LL t=x*(x+1)/2*(y+1)+y*(y+1)/2*(x+1); ma=max(t,ma); } printf("%lld\n",ma); return 0;}

 

 

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

你可能感兴趣的文章
mysql 行函数_MySQL -- 单行函数
查看>>
mysql8.0.11发布时间_MySQL 8.0 正式版 8.0.11 发布,比 MySQL 互联网技术圈 互联网技术圈...
查看>>
mysql 6.5.7_centos 6.5装mysql5.7
查看>>
mysql执行ef_EF链接mysql 和mysql 执行语句 监控
查看>>
图解全排列问题_递归实现全排列
查看>>
mysql c语言扩展_用C语言扩展PHP功能
查看>>
mysql 服务器集群_轻松构建MySQL高可用集群系统
查看>>
java 判断题_Java判断题汇总.doc
查看>>
java 公网ip_JAVA获取公网ip
查看>>
java 变参数_Java_可变参数
查看>>
redis sscan java_redis 用scan 代替keys,hgetAll
查看>>
mysql不支持union_MySQL中Union子句不支持order by的解决方法
查看>>
java 多线程并发 问题_java并发编程线程问题分析
查看>>
php反序列化java.long_jquery与php结合实现AJAX长轮询(LongPoll)
查看>>
spark java_spark基本操作 java 版
查看>>
大王java_Java NIO原理和使用
查看>>
java 按钮竖行排列_Java Swing(初学者):有6个文本框竖直排列和两个按钮(bt1和bt2),默认焦点在第一个文本框上。...
查看>>
JAVA计算含未知数的方程_求解具有两个未知数的两个方程的系统
查看>>
java面试ssm6_面试题 - osc_m616vxy7的个人空间 - OSCHINA - 中文开源技术交流社区
查看>>
java过滤器往后传参数_Spring security 自定义过滤器实现Json参数传递并兼容表单参数(实例代码)...
查看>>