题意:就是从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…
任意门: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 题意很简单,有序列 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 题目大意: 求解两个不相等的正整数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.就变成了典型的…
 强伪素数 题目大意:利用费马定理找出强伪素数(就是本身是合数,但是满足费马定理的那些Carmichael Numbers) 很简单的一题,连费马小定理都不用要,不过就是要用暴力判断素数的方法先确定是不是素数,然后还有一个很重要的问题,那就是a和p是不互质的,不要用a^(p-1)=1(mod p)这个判据,比如4^6=4(mod 6),但是4^5=4(mod 6) #include <iostream> #include <functional> #include <algo…
题意:给定一个N,求一个大于N的最小的Smith Numbers,Smith Numbers是一个合数,且分解质因数之后上质因子每一位上的数字之和 等于 其本身每一位数字之和(别的博客偷的题意) 思路:主要是分治:分解成质因子使用递归即可. #include<cstdio> #include<cmath> // 检测素数 bool is_prime(int n) { ; i*i <= n;++i) ){ ; } ; } //数位 int sumfun(int n) { ; ;…
直接看代码就OK.思路比较简单.就是注意概率要在转移过程中算出来.不能算成成立的方案书除以总方案数(POJ的这道题可以这么干.数据很水么.另外POJ要用%.5f,%.5lf 会WA.) #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #inclu…