ZOJ 3702 Gibonacci number(数学推导)
公式推导题,G(0) = 1,G(1) = t,给出一个 i 和 G(i),要求求出G(j)的值;
G(0) = 0*t + 1
G(1) = 1*t + 0; 观察t的系数和常数值可以知道二者都遵循斐波那契的规律,设系数值为Y(n),常数值为X(n);
G(2) = 1*t + 1; Y(0) = 0,Y(1) = 1;
G(3) = 2*t + 1; X(0) = 1, X(1) = 0;
G(4) = 3*t + 2; 这样就能求出答案了,最后的t满足要求就有解
G(5) = 5*t + 3;
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
long long x[],y[];
void init()
{
x[]=,x[]=;
y[]=,y[]=;
for(int i=; i<=; i++)
{
x[i]=x[i-]+x[i-];
y[i]=y[i-]+y[i-];
}
}
int main()
{
int T;
init();
scanf("%d",&T);
int i,gi,j;
while(T--)
{
scanf("%d%d%d",&i,&gi,&j);
long long t;
t=(gi-x[i])/y[i];
if((gi-x[i])%y[i]!=||t<)
printf("-1\n");
else
printf("%lld\n",x[j]+t*y[j]);
}
return ;
}
ZOJ 3702 Gibonacci number(数学推导)的更多相关文章
- ZOJ 3702 Gibonacci number 2017-04-06 23:28 28人阅读 评论(0) 收藏
Gibonacci number Time Limit: 2 Seconds Memory Limit: 65536 KB In mathematical terms, the normal ...
- ZOJ 3702 Gibonacci number
本来已经关上电脑了 但还是想打开电脑纪念一下这充实的一天…… 第一节高数课讲新课级数 讲完一个知识点 想问问女票今天咋又没来上课…… 突然发现院长问我自费去不去省赛…… !!! 当然是去啊! ……虽然 ...
- zoj.3868.GCD Expectation(数学推导>>容斥原理)
GCD Expectation Time Limit: 4 Seconds Memory Limit: 262144 KB ...
- zoj 1526 Big Number 数学
Big Number Time Limit: 10 Seconds Memory Limit: 32768 KB In many applications very large intege ...
- 关于不同进制数之间转换的数学推导【Written By KillerLegend】
关于不同进制数之间转换的数学推导 涉及范围:正整数范围内二进制(Binary),八进制(Octonary),十进制(Decimal),十六进制(hexadecimal)之间的转换 数的进制有多种,比如 ...
- UVA - 10014 - Simple calculations (经典的数学推导题!!)
UVA - 10014 Simple calculations Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & ...
- HDU 5073 Galaxy(Anshan 2014)(数学推导,贪婪)
Galaxy Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total S ...
- HDU-1719 Friend 数学推导
Friend HDU - 1719 Friend number are defined recursively as follows. (1) numbers 1 and 2 are friend n ...
- 借One-Class-SVM回顾SMO在SVM中的数学推导--记录毕业论文5
上篇记录了一些决策树算法,这篇是借OC-SVM填回SMO在SVM中的数学推导这个坑. 参考文献: http://research.microsoft.com/pubs/69644/tr-98-14.p ...
随机推荐
- python+appium使用记录
最近在研究appium+appiumlibrary移动端的两个自动化测试库,特此将使用过程,粗略记录一下 1.环境搭建,略,自行百度. 2.查看apk包名及activity方法,自行百度. 3.基本步 ...
- LeetCode OJ 98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as ...
- uCGUI的文字与数值显示方法
uCGUI的数值显示非常的灵活方便,是制作LCD界面非常好的选择. 文字与数值显示的方法: 常用文本显示函数: void GUI_DispStringAt(const char GUI_FAR *s, ...
- JavaScript的第一次小结
一. JavaScript是一种的脚本语言:特点是:具有解释性,基于对象,事件驱动,安全性和跨平台等特点 对于这几种特点有必要说明一下 解释性:就是JavaScripte本身就是一种解释性语言 基于对 ...
- 【中国剩余定理】 poj 1006
生理周期 简单模拟 对于超出23 * 28 * 33(21252)时进行求余运算即可. #include<stdio.h> int main() { //freopen("in ...
- Games on a CD
Games on a CD time limit per test 4 seconds memory limit per test 512 megabytes input standard input ...
- 破解MyEclipse2013注册码
1.下载破解工具 http://down8.3987.com:801/2010/Myeclipse_zcj.3987.com.rar 2.打开 找到meclipse安装路径找到plugins文件夹打开 ...
- 关于js向jsp中传输中文乱码问题
最近做项目遇到的js向jsp中传中文结果是乱码,不知道是否是我换了用eclipse的原因还是什么,以前用的MyEclipse反正最后解决办法如下: 1.把js文件复制到桌面: 2.打开文件并用另存为u ...
- if __name__ == '__main__'在python中的应用
当你打开一个.py文件时,经常会在代码的最下面看到if __name__ == '__main__':,现在就来介 绍一下它的作用. 模块是对象,并且所有的模块都有一个内置属性 __name__.一个 ...
- 查看log的方法
adb logcat>1.txt adb shell cat /proc/atf_log/atf_log > atf_log 会保存在adb的本地文件. 还有一种是实时读取的方式: adb ...