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 <<" " <
  • 相关阅读:
    Django + Uwsgi + Nginx 的概念
    ubantu+nginx+uwsgi+django部署
    FileZilla以root用户登录Linux
    全文检索django-haystack+jieba+whoosh
    七牛云上传视频
    JWT登录与多方式登录
    vue绑定用户页面
    绑定微博用户接口
    vue微博回调空页面
    微博回调接口
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/7189677.html
Copyright © 2011-2022 走看看