zoukankan      html  css  js  c++  java
  • Street Numbers POJ

    题意:就是从n到1再从1到n的各个数字之和为sum1, 然后从n到m,再从m到n的各个数字之和为sum2,求,(n,m)的前10组解。

    思路:   直接建模,利用等差数列的求和公式计算一个公式(2n+1)^2 - m^2=1;   然后直接佩尔方程式即可!

    #include<cstdio>
    #include<cmath>
    #define ll long long
    int main()
    {
        int x, y, x1, y1, px, py;
        x1 = 3;    y1 = 1;
        px = 3; py = 1;
        for (int i = 0; i < 10; ++i)
        {
            x = px*x1 + 8 * py*y1;    y = py*x1 + px*y1;
            printf("%10d%10d
    ", y, (x - 1) / 2);
            px = x; py = y;
        }
    }
    #include<cstdio>
    #include<cmath>
    #define ll long long
    int main()
    {
        int x, y, x1, y1, px, py;
        x1 = 3;    y1 = 1;
        px = 3; py = 1;
        for (int i = 0; i < 10; ++i)
        {
            x = px*x1 + 8 * py*y1;    y = py*x1 + px*y1;
            printf("%10d%10d
    ", y, (x - 1) / 2);
            px = x; py = y;
        }
    }
    #include<cstdio>
    #include<cmath>
    #define ll long long
    int main()
    {
        int x, y, x1, y1, px, py;
        x1 = 3;    y1 = 1;
        px = 3; py = 1;
        for (int i = 0; i < 10; ++i)
        {
            x = px*x1 + 8 * py*y1;    y = py*x1 + px*y1;
            printf("%10d%10d
    ", y, (x - 1) / 2);
            px = x; py = y;
        }
    }
  • 相关阅读:
    开发趋势
    常用的meta
    meta基础
    HTTP请求方法GET和POST
    same-origin policy----wikipedia
    跨域——同源策略(译)
    DNS问答
    TCP/IP的整理
    鉴权方法
    Web攻击技术---OWASP top
  • 原文地址:https://www.cnblogs.com/ALINGMAOMAO/p/9757697.html
Copyright © 2011-2022 走看看