题意:就是从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 = ; y1 = ;
px = ; py = ;
for (int i = ; i < ; ++i)
{
x = px*x1 + * py*y1; y = py*x1 + px*y1;
printf("%10d%10d\n", y, (x - ) / );
px = x; py = y;
}
}
#include<cstdio>
#include<cmath>
#define ll long long
int main()
{
int x, y, x1, y1, px, py;
x1 = ; y1 = ;
px = ; py = ;
for (int i = ; i < ; ++i)
{
x = px*x1 + * py*y1; y = py*x1 + px*y1;
printf("%10d%10d\n", y, (x - ) / );
px = x; py = y;
}
}
#include<cstdio>
#include<cmath>
#define ll long long
int main()
{
int x, y, x1, y1, px, py;
x1 = ; y1 = ;
px = ; py = ;
for (int i = ; i < ; ++i)
{
x = px*x1 + * py*y1; y = py*x1 + px*y1;
printf("%10d%10d\n", y, (x - ) / );
px = x; py = y;
}
}

Street Numbers POJ - 1320(佩尔方程式)的更多相关文章

  1. POJ 1320 Street Numbers 【佩尔方程】

    任意门:http://poj.org/problem?id=1320 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Su ...

  2. POJ 1320 Street Numbers 解佩尔方程

    传送门 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2529   Accepted: 140 ...

  3. POJ 1320 Street Numbers(佩尔方程)

    Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3078   Accepted: 1725 De ...

  4. POJ 1320:Street Numbers

    Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2753   Accepted: 1530 De ...

  5. POJ 1320 Street Numbers Pell方程

    http://poj.org/problem?id=1320 题意很简单,有序列 1,2,3...(a-1),a,(a+1)...b  要使以a为分界的 前缀和 和 后缀和 相等 求a,b 因为序列很 ...

  6. POJ1320 Street Numbers【佩尔方程】

    主题链接: http://poj.org/problem?id=1320 题目大意: 求解两个不相等的正整数N.M(N<M),使得 1 + 2 + - + N = (N+1) + - + M.输 ...

  7. Mathematics:Pseudoprime numbers(POJ 3641)

     强伪素数 题目大意:利用费马定理找出强伪素数(就是本身是合数,但是满足费马定理的那些Carmichael Numbers) 很简单的一题,连费马小定理都不用要,不过就是要用暴力判断素数的方法先确定是 ...

  8. Smith Numbers POJ - 1142 (暴力+分治)

    题意:给定一个N,求一个大于N的最小的Smith Numbers,Smith Numbers是一个合数,且分解质因数之后上质因子每一位上的数字之和 等于 其本身每一位数字之和(别的博客偷的题意) 思路 ...

  9. UVA 10081 Tight numbers(POJ 2537)

    直接看代码就OK.思路比较简单.就是注意概率要在转移过程中算出来.不能算成成立的方案书除以总方案数(POJ的这道题可以这么干.数据很水么.另外POJ要用%.5f,%.5lf 会WA.) #includ ...

随机推荐

  1. 安装searchd

    把安装包解压到 D:coreseek 创建表 create table product( id int key auto_increment, title ), content text ); ins ...

  2. 牛刀小试MySQL--innodb_flush_log_at_trx_commit小结

    参数名:innodb_flush_log_at_trx_commit 参数值: 0 事务提交的时候,不会去刷日志缓存区,也不会立马写入至日志文件中.这种设置最危险.如果数据库挂了且运气不好,数据库的最 ...

  3. Ado.net怎么执行存储过程?

    与ADO.Net执行SQL语句的地方只有两点不同1.使用存储过程名代替sql语句2. 使用查询对象SqlCommand,需配置一个CommandType属性 存储过程的执行语法-> exec 存 ...

  4. Flask 中的 特殊装饰器before_request/after_request

    before_request :在请求收到之前绑定一个函数做一些事情. after_request: 每一个请求之后绑定一个函数,如果请求没有异常. teardown_request: 每一个请求之后 ...

  5. Design--源自生活美学的色彩搭配网站(design-seeds)

    All the flowers of all the tomorrows are in the seeds of today. 色彩搭配网站--design-seeds.com // 所有的颜色值都是 ...

  6. react-router与react-router-dom使用时的区别

    1.React-router与React-router-dom的API对比 React-router:提供了router的核心api.如Router.Route.Switch等,但没有提供有关dom操 ...

  7. vue-cli脚手架之webpack.dev.conf.js

    webpack.dev.conf.js  开发环境模式配置文件: 'use strict'//js按照严格模式执行 const utils = require('./utils')//导入utils. ...

  8. 纯小白入手 vue3.0 CLI - 3.1 - 路由 ( router )

    vue3.0 CLI 真小白一步一步入手全教程系列:https://www.cnblogs.com/ndos/category/1295752.html 尽量把纷繁的知识,肢解重组成为可以堆砌的知识. ...

  9. 【转】64位系统下无法使用libpam-mysql的md5

    转自:http://superwf.dyndns.info/?p=331 Aug 23 09:05:57 wfoffice saslauthd[7235]: pam_mysql – non-crypt ...

  10. Scala之List,Set及Map基本操作

    package big.data.analyse.dataSet import scala.collection.immutable.{TreeMap, TreeSet} import scala.c ...