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 ...
随机推荐
- pat1050. String Subtraction (20)
1050. String Subtraction (20) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Giv ...
- InnoDB还是MyISAM?
两种类型最主要的差别就是Innodb 支持事务处理与外键和行级锁.而MyISAM不支持.所以MyISAM往往就容易被人认为只适合在小项目中使用. 我作为使用MySQL的用户角度出发,Innodb和My ...
- 基础10 多进程、协程(multiprocessing、greenlet、gevent、gevent.monkey、select、selector)
1.多进程实现方式(类似于多线程) import multiprocessing import time,threading def thread_run():#定义一个线程函数 print(&quo ...
- .NET面试题4
常见面试题目: 1.字符串是引用类型类型还是值类型? 2.在字符串连接处理中,最好采用什么方式,理由是什么? 3.使用 StringBuilder时,需要注意些什么问题? 4.以下代码执行后内存中会存 ...
- NET平台4.0 发布网站流程及出错总结
1.进入IIS设置,在控制面板中选择“管理工具”,进入后选择 “Internet 信息服务(IIS)管理器” 2.点击[添加]应用程序池,根据版本选择framework 3.添加网站 ,右击网站,添加 ...
- 解决jQuery在chrome中获取height为0
笔者之前在一家创业公司做过项目,当时遇到这么一个奇怪的问题,我需要用一个jQuery的height()方法获取一个div的高度,但是在chrome浏览器上面有时可以正常获取,但是同一个页面刷新多几次获 ...
- jq中事件绑定的方法
在唯品会实习生面试中,被面试官问了这么一个问题,“jQuery中绑定事件的方法有几个?”,以click事件为例,我当时想到的只有.click(),.bind(),.on()这三种,然后面试官又追问,“ ...
- cf633F. The Chocolate Spree(树形dp)
题意 题目链接 \(n\)个节点的树,点有点权,找出互不相交的两条链,使得权值和最大 Sol 这辈子也不会写树形dp的 也就是有几种情况,可以讨论一下.. 下文的"最大值"指的是& ...
- es6-正则
RegExp构造函数 在ES5中,RegExp构造函数的参数有两种情况. 第一种情况是,参数是字符串,这时第二个参数表示正则表达式的修饰符(flag). var regex = new RegExp( ...
- REP-0118:can not create temporary file(无法创建临时文件)
解决办法: 查看一下注册表里面的reports_tmp 的路径 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_DevSuiteHome1 .是不 ...