poj_1320_Street Numbers
Write a program to find pairs of numbers that satisfy this condition. To start your list the first two pairs are: (house number, last number):
6 8
35 49
Input
Output
Sample Input
Sample Output
6 8
35 49
题意 k号房子分开n栋房子,前k-1栋和等于k+1到第n栋。输出k,n。
网上题解大多瞎XX扯X,证明不完整,推导胡说八道直接给出佩尔方程。我直接暴力打印前几组找到了规律
6 8
35 49
204 288
1189 1681
到这里我就发现了,
204=35*6-6 288=204+35+49
1189=204*6-35 1681=1189+204+288
a[i]=a[i-1]*6-a[i-2]
b[i]=a[i]+a[i-1]+b[i-1]
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define N 1000010
using namespace std;
typedef long long ll;
int a[11];
int b[11];
int main()
{
// freopen("dataout.txt","w",stdout);
a[0]=6;
a[1]=35;
b[0]=8;
b[1]=49;
printf("%10d%10d\n",6,8);
printf("%10d%10d\n",35,49);
for(int i=2;i<10;i++)
{
a[i]=a[i-1]*6-a[i-2];
b[i]=a[i]+a[i-1]+b[i-1];
int x=a[i],y=b[i];
printf("%10d%10d\n",a[i],b[i]);
} }
poj_1320_Street Numbers的更多相关文章
- Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range
在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- [LeetCode] Add Two Numbers II 两个数字相加之二
You are given two linked lists representing two non-negative numbers. The most significant digit com ...
- [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字
Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Bitwise AND of Numbers Range 数字范围位相与
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...
- [LeetCode] Valid Phone Numbers 验证电话号码
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- [LeetCode] Consecutive Numbers 连续的数字
Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...
- [LeetCode] Compare Version Numbers 版本比较
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...
随机推荐
- nginx 访问路径配置
比如: http://127.0.0.1/ 对应的物理路径 c:/a/b/c 比如:http://127.0.0.1/eec 访问的地址对应的物理路径: d:/a/b/c #user nobody; ...
- mongodb开机启动
#!/bin/bash # #chkconfig: #description: mongodb start() { /usr/local/mongodb/bin/mongod --dbpath=/us ...
- 《Flink 源码解析》—— 源码编译运行
更新一篇知识星球里面的源码分析文章,去年写的,周末自己录了个视频,大家看下效果好吗?如果好的话,后面补录发在知识星球里面的其他源码解析文章. 前言 之前自己本地 clone 了 Flink 的源码,编 ...
- maven实战迷你版记录
1. ~/.m2 文件 默认情况下,该文件夹下放置了 Maven 本地 仓库.m2/repository.所有的 Maven 构件(artifact)都被存储到该仓库中,以方便重用. 默认情况下,~ ...
- 重启部署在Linux系统下的tomcat服务
重启部署在Linux系统下的tomcat服务具体的操作步骤: 1.在Winscp上建立连接,输入用户和密码,这个密码一般是看不到的: 2.查看服务:ps -ef | gerp Java 注意在 ...
- HTML--备忘点
1.文档内的链接
- deployment删除后,副本集未删除,解决之道
在删除的body上加上,body.setPropagationPolicy("Foreground");就可以删除deployment的同时连同副本集一同删除.
- Gulp工具常用插件
gulp-uglify(js压缩) gulp-uglify安装 // npm install --save-dev gulp-uglify 已过时 npm install --save-dev jsh ...
- <Android 基础(十三)> shape
介绍 简单来说,shape就是用来在xml文件中定义形状,代码解析之后就可以当做Drawable一样使用 官方说明 关于shape定义的drawable 文件位置:res/drawable/filen ...
- linux系统unzip文件报错的解决方案
data.zip文件有4G多,解压的时候出问题了. Archive: data.zip End-of-central-directorysignature not found. Either th ...