zoukankan
html css js c++ java
斐波那契数列 二分法 取后四位 PKU 3070
Code
#include
<
iostream
>
using
namespace
std;
int
ans[
2
][
2
];
int
mid[
2
][
2
];
void
init(
int
a[
2
][
2
],
int
b[
2
][
2
],
int
mark )
{
int
i, j, temp[
2
][
2
];
temp[
0
][
0
]
=
( a[
0
][
0
]
*
b[
0
][
0
]
+
a[
0
][
1
]
*
b[
1
][
0
] )
%
10000
;
temp[
0
][
1
]
=
( a[
0
][
0
]
*
b[
0
][
1
]
+
a[
0
][
1
]
*
b[
1
][
1
] )
%
10000
;
temp[
1
][
0
]
=
( a[
1
][
0
]
*
b[
0
][
0
]
+
a[
1
][
1
]
*
b[
1
][
0
] )
%
10000
;
temp[
1
][
1
]
=
( a[
1
][
0
]
*
b[
0
][
1
]
+
a[
1
][
1
]
*
b[
1
][
1
] )
%
10000
;
if
( mark
==
1
)
{
for
( i
=
0
; i
<
2
; i
++
)
{
for
( j
=
0
; j
<
2
; j
++
)
{
ans[i][j]
=
temp[i][j];
}
}
}
if
( mark
==
0
)
{
for
( i
=
0
; i
<
2
; i
++
)
{
for
( j
=
0
; j
<
2
; j
++
)
{
mid[i][j]
=
temp[i][j];
}
}
}
}
void
cal (
int
n )
{
while
( n )
{
if
( n
%
2
==
1
)
{
init ( ans, mid,
1
);
}
init ( mid, mid,
0
);
n
/=
2
;
}
}
int
main ()
{
int
n;
while
( scanf (
"
%d
"
,
&
n )
&&
n
!=
-
1
)
{
ans[
0
][
0
]
=
1
; ans[
0
][
1
]
=
0
; ans[
1
][
0
]
=
0
; ans[
1
][
1
]
=
1
;
mid[
0
][
0
]
=
1
; mid[
0
][
1
]
=
1
; mid[
1
][
0
]
=
1
; mid[
1
][
1
]
=
0
;
cal (n);
printf (
"
%d\n
"
, ans[
0
][
1
] );
}
return
0
;
}
查看全文
相关阅读:
springboot CRUD+分页(基于JPA规范)
springboot中yml配置文件
springboot中配置切换
springboot中修改端口和上下文路径
springboot中全局异常处理器
springboot热部署
新的表格展示利器 Bootstrap Table Ⅰ
关于html转换为pdf案例的一些测试与思考
java设计模式 策略模式Strategy
java设计模式 模板方法模式Template Method
原文地址:https://www.cnblogs.com/Knuth/p/1559841.html
最新文章
kafka监控工具kafkaOffsetMoniter的使用
kafka监控工具kafkaOffsetMoniter的使用
阿里云监控
Jenkins构建时间Poll Scm的设置(常用设置)
阿里云自定义监控
Kafka管理工具介绍
IDEA设置热部署
eclipse设置maven web项目打包
Spring源码构建
单例模式总结
热门文章
工厂模式总结
redis集群报错:(error) CLUSTERDOWN The cluster is down
设计模式-软件设计原则7-合成复用原则
设计模式-软件设计原则5-迪米特 法则
设计模式-软件设计原则4-接口隔离原则
设计模式-软件设计原则3-依赖倒置原则
com.mysql.jdbc.MysqlDataTruncation:Data Truncation:Data too long for column '字段name' at row 1
springboot之restful风格
springboot上传图片文件
springboot CRUD+分页(基于Mybatis注解方式)
Copyright © 2011-2022 走看看