3713: [PA2014]Iloczyn

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 327  Solved: 181
[Submit][Status][Discuss]

Description

斐波那契数列的定义为:k=0或1时,F[k]=k;k>1时,F[k]=F[k-1]+F[k-2]。数列的开头几项为0,1,1,2,3,5,8,13,21,34,55,…你的任务是判断给定的数字能否被表示成两个斐波那契数的乘积。

Input

第一行包含一个整数t(1<=t<=10),表示询问数量。接下来t行,每行一个整数n_i(0<=n_i<=10^9)。

Output

输出共t行,第i行为TAK(是)或NIE(否),表示n_i能否被表示成两个斐波那契数的乘积。

Sample Input

5
5
4
12
11
10

Sample Output

TAK
TAK
NIE
NIE
TAK

HINT

 

Source

鸣谢Jcvb

题解:一开始我还想着怎么预处理,但是后来发现貌似也就\( \log M \)个数字(虽然显然没这么少,但实际上也就不超过60个的样子)在\( {10}^{9} \)一下,然后\( T \leq 10 \),暴力枚举轻松水过(PS:呵呵呵逗比的我还用了个平衡树来维护,但后来才想到貌似二分查找就够了= =)

 /**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
a:array[..] of int64;
lef,rig,fix:array[..] of longint;
i,j,k,l,m,n,head,t:longint;
a1:int64;
procedure rt(var x:longint);
var f,l:longint;
begin
if (x=) or (lef[x]=) then exit;
f:=x;l:=lef[x];
lef[f]:=rig[l];
rig[l]:=f;
x:=l;
end;
procedure lt(var x:longint);
var f,r:longint;
begin
if (x=) or (rig[x]=) then exit;
f:=x;r:=rig[x];
rig[f]:=lef[r];
lef[r]:=f;
x:=r;
end;
procedure ins(var x:longint;y:longint);
begin
if x= then
begin
x:=y;
exit;
end;
if a[y]<=a[x] then
begin
if lef[x]= then lef[x]:=y else ins(lef[x],y);
if fix[lef[x]]<fix[x] then rt(x);
end
else
begin
if rig[x]= then rig[x]:=y else ins(rig[x],y);
if fix[rig[x]]<fix[x] then lt(x);
end;
end;
function check(x:longint;y:int64):boolean;
begin
if x= then exit(false);
if a[x]=y then exit(true);
if y<a[x] then exit(check(lef[x],y)) else exit(check(rig[x],y));
end;
begin
a[]:=;a[]:=;head:=;randomize;
for i:= to do a[i]:=a[i-]+a[i-];
for i:= to do
begin
lef[i]:=;rig[i]:=;fix[i]:=random(maxlongint);
ins(head,i);
end;
readln(t);
while t> do
begin
readln(a1);
if a1= then writeln('TAK') else
begin
j:=;
for i:= to do
begin
if a[i]>a1 then break;
if (a1 mod a[i])<> then continue;
if check(head,a1 div a[i]) then
begin
j:=;writeln('TAK');
break;
end;
end;
if j= then writeln('NIE');
end;
dec(t);
end;
readln;
end.

3713: [PA2014]Iloczyn的更多相关文章

  1. BZOJ 3713: [PA2014]Iloczyn( 枚举 )

    斐波那契数列<10^9的数很少很少...所以直接暴力枚举就行了... ------------------------------------------------------------- ...

  2. BZOJ 3713: [PA2014]Iloczyn

    Description 斐波那契数列的定义为:k=0或1时,F[k]=k:k>1时,F[k]=F[k-1]+F[k-2].数列的开头几项为0,1,1,2,3,5,8,13,21,34,55,-你 ...

  3. BZOJ3713: [PA2014]Iloczyn

    3713: [PA2014]Iloczyn Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 206  Solved: 112[Submit][Status ...

  4. bzoj3713: [PA2014]Iloczyn(乱搞)

    3713: [PA2014]Iloczyn 题目:传送门 题解: 随手一发水题x2 直接离线啊,斐波那契到了第五十个就炒鸡大了 代码: #include<cstdio> #include& ...

  5. [PA2014]Iloczyn

    [PA2014]Iloczyn 题目大意: 询问\(n(n\le10^9)\)是否是两个斐波那契数之积. 思路: \({\rm fib}(45)<10^9,{\rm fib}(46)>10 ...

  6. bzoj3713 [PA2014]Iloczyn|暴力(模拟)

    斐波那契数列的定义为:k=0或1时,F[k]=k:k>1时,F[k]=F[k-1]+F[k-2].数列的开头几项为0,1,1,2,3,5,8,13,21,34,55,-你的任务是判断给定的数字能 ...

  7. 【暴力】bzoj3713 [PA2014]Iloczyn

    没什么好说的. #include<cstdio> using namespace std; typedef long long ll; ]; int main() { scanf(]=; ...

  8. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  9. [PA2014] [BZOJ 3709]~[BZOJ 3719] 合集

    今天起尝试做套题喵~ (当然是因为被最大流的题目弄得恶心死了) 一共是 10 道题一道一道做 预计 3~4 内做完 尽情期待 [BZOJ 3709]Bohater 一眼就能感受到贪心的气息 因为很直观 ...

随机推荐

  1. 使用Eclipse开发及测试Spark的环境搭建及简单测试

    一.下载专门开发的Scala的Eclipse 1.下载地址:http://scala-ide.org/download/sdk.html,或链接:http://pan.baidu.com/s/1hre ...

  2. Oracle Job 语法和时间间隔的设定(转)

    http://blog.itpub.net/27157/viewspace-425567/ 初始化相关参数job_queue_processesalter system set job_queue_p ...

  3. Canvas get/putImageData

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. jQuery实践-别踩白块儿网页版

    ▓▓▓▓▓▓ 大致介绍 终于结束了考试,放假回家了.这次的别踩白块儿网页版要比之前做的 jQuery实践-网页版2048小游戏 要简单一点,基本的思路都差不多. 预览:别踩白块网页版 这篇博客并不是详 ...

  5. 支付宝ios支付请求Java服务端签名报的一个错(ALI40247) 原创

    今天做app的支付宝支付,遇到些问题,以前做支付宝支付签名都是直接在客户端App进行,今天下了最新版本ios的支付宝支付demo,运行demo时底部有红色的显眼字体,告知用户签名必须在服务端进行... ...

  6. LinQ 创建连接、简单增删改查

    LINQ--语言集成查询(Language Integrated Query)是一组用于c#和Visual Basic语言的扩展.它允许编写C#或者Visual Basic代码以查询数据库相同的方式操 ...

  7. 源码(07) -- java.util.Iterator<E>

    java.util.Iterator<E> 源码分析(JDK1.7) ----------------------------------------------------------- ...

  8. CTR预估中的贝叶斯平滑方法及其代码实现

    1. 背景介绍 广告形式: 互联网广告可以分为以下三种: 1)展示广告(display ad) 2)搜索广告(sponsored search ad) 3)上下文广告(contextual ad)   ...

  9. Jenkins权限配置失误后导致登录失败的解决办法

    为了便于管理,Jenkins一般需要设置用户,而且这些用户是需要配置相应的权限的,如果一不小心配置的时候出了问题,那么,你就斯巴达了. 这里,用我的切身经历,为大家说一下Jenkins因为权限配置失误 ...

  10. 基于canvas的二维码邀请函生成插件

    去年是最忙碌的一年,实在没时间写博客了,看着互联网行业中一个又一个人的倒下,奉劝大家,健康要放在首位,保重身体.好了,言归正传,这是17年的第一篇博文,话说这天又是产品同学跑过来问我说:hi,lenn ...