zoukankan      html  css  js  c++  java
  • CF821 B. Okabe and Banana Trees 简单数学

    Link

    题意:给出一条直线,在直线上取一点,其垂直x,y轴作成一个,求矩阵中所有包含的点的x,y坐标之和的最大值。

    思路:对于一个任意一点我们计算公式,对于任意一点$(x, y)$,有$(x+y)^2 + (x+y)(xy+1)$,枚举一个未知量,得另一个未知量向下取整即可。

    /** @Date    : 2017-07-04 14:52:58
      * @FileName: B 数学.cpp
      * @Platform: Windows
      * @Author  : Lweleth (SoungEarlf@gmail.com)
      * @Link    : https://github.com/
      * @Version : $Id$
      */
    #include <bits/stdc++.h>
    #define LL long long
    #define PII pair
    #define MP(x, y) make_pair((x),(y))
    #define fi first
    #define se second
    #define PB(x) push_back((x))
    #define MMG(x) memset((x), -1,sizeof(x))
    #define MMF(x) memset((x),0,sizeof(x))
    #define MMI(x) memset((x), INF, sizeof(x))
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    const int N = 1e5+20;
    const double eps = 1e-8;
    
    
    int main()
    {
    	double m, b;
    	while(cin >> m >> b)
    	{
    		double len = m * b;
    		LL ma = 0;
    		for(double x = 0; x <= len; x+=1)
    		{
    			double y = floor(b - x / m);
    			LL t = (LL)(x + y) * (x + y) + (LL)(x + y)*(x * y + 1);
    			ma = max(ma, t);
    			//cout << x << y <<" " <
  • 相关阅读:
    杭电2042
    杭电2041
    杭电2040
    杭电2046
    SPOJ
    SPOJ
    SPOJ
    HDU
    HDU
    HDU
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/7189677.html
Copyright © 2011-2022 走看看