POJ 1320 Street Numbers 【佩尔方程】】的更多相关文章

http://poj.org/problem?id=1320 题意很简单,有序列 1,2,3...(a-1),a,(a+1)...b  要使以a为分界的 前缀和 和 后缀和 相等 求a,b 因为序列很特殊所以我们用数学方法就可以解决 : 求和:  a*(a-1)/2 = (a+1+b)(b-a)/2 化简: 2a2  = b2 + b 两边乘4,构造完全平方项 (2b+1)2 - 8a2  = 1 令 x = 2*b+1; y = a; 我们就得到了一个形如Pell方程x2 - Dy2  = 1…
任意门:http://poj.org/problem?id=1320 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3181   Accepted: 1776 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the…
传送门 Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2529   Accepted: 1406 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks…
Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3078   Accepted: 1725 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her…
Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2753   Accepted: 1530 Description A computer programmer lives in a street with houses numbered consecutively (from 1) down one side of the street. Every evening she walks her…
主题链接: http://poj.org/problem?id=1320 题目大意: 求解两个不相等的正整数N.M(N<M),使得 1 + 2 + - + N = (N+1) + - + M.输出前10组满足要求 的(N,M). 思路: 要使 1 + 2 + - + N = (N+1) + - + M,那么 N*(N+1)/2 = (M-N)(M+N+1)/2,即 (2*M+1)^2 - 8*N^2 - 1.令x = 2*M + 1.y = N,就有x^2 - 8*y^2 = 1.就变成了典型的…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=3292 No more tricks, Mr Nanguo Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 587    Accepted Submission(s): 400 Problem Description Now Sailormoon…
一.题目大意 本题要求写出前5482个仅能被2,3,5, 7 整除的数. 二.题解 这道题从本质上和Poj 1338 Ugly Numbers(数学推导)是一样的原理,只需要在原来的基础上加上7的运算即可.还有一个不同之处在于输出上,这个题要求第n的英语表示.而英语中的表示呢,如果n的个位数是1,用nst表示个位数是2的用,nnd表示:个位数是3的,用nrd表示.但是n的最后两位是11.12.13的还是用nth表示,其他的也是用th表示. 三.java代码 import java.util.Sc…
#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <math.h> using namespace std;   int can[1005] = {0}; int a[10005][605]= {0}; int x[6005], y[6005], t[6005]; int h1,h2; int bb, ee, xx, y…
作弊了--!该题可以通过因式分解得到一个佩尔方程....要不是学着这章,估计想不到.. 得到x1,y1后,就直接代入递推式递推了 x[n]=x[n-1]*x[1]+d*y[n-1]*y[1] y[n]=x[n-1]*y[1]+y[n-1]*x[1] #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int mai…