题意:求n个斐波那契数列组合都无法得到的最小数字

解法:

1 我们先暴力的求出前面几个数字

2 然后再暴力的求递推

3 接着矩阵快速幂(没写错吧?)

/*#include<bits/stdc++.h>
using namespace std;
long long x[50];
map<long long,int>Mp;
void dfs(int pos,long long sum,int cnt,int n){
if(cnt==n){
Mp[sum]=1;
return;
}
if(cnt>n){
return;
}
for(int i=pos;i<=20;i++){
dfs(i+1,sum+x[i],cnt+1,n);
}
}
int main(){
x[0]=0;
x[1]=1;
for(int i=2;i<=21;i++){
x[i]=x[i-1]+x[i-2];
}
for(int i=0;i<=21;i++){
Mp[x[i]]=1;
}
//dfs(0,0,0,3);
for(int i=2;i<=5;i++){ dfs(0,0,0,i);
for(long long j=0;j<=x[21];j++){
if(Mp[j]==0){
cout<<j<<endl;
break;
}
}
}
return 0;
}*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define mset(a,i) memset(a,i,sizeof(a))
using namespace std;
typedef long long ll;
const int mod=;
struct Mal{
ll x[][];
};
Mal mul(Mal a,Mal b){
Mal c;
memset(c.x,,sizeof(c.x));
for(int i=;i<;i++){
for(int j=;j<;j++){
for(int k=;k<;k++){
c.x[i][j]+=((a.x[i][k]+mod)*(b.x[k][j]+mod))%mod;
c.x[i][j]%=mod;
}
}
}
return c;
}
Mal Qp(int n){
Mal a,b;
memset(a.x,,sizeof(a.x));
memset(b.x,,sizeof(b.x));
a.x[][]=;
a.x[][]=-;
a.x[][]=;
a.x[][]=;
a.x[][]=;
for(int i=;i<;i++){
b.x[i][i]=;
}
while(n){
if(n&){
b=mul(b,a);
}
a=mul(a,a);
n/=;
}
return b;
}
ll k;
int main(){
while(~scanf("%lld",&k)){
if(k==){
cout<<""<<endl;
continue;
}
if(k==){
cout<<""<<endl;
continue;
}
Mal pos,X;
pos.x[][]=;
pos.x[][]=;
pos.x[][]=;
X=mul(Qp(k-),pos);
ll ans=X.x[][]%mod;
printf("%lld\n",ans);
}
return ;
}
/*
1 2 3 4 5 6 7 8 9 10 11 12
4
12
33
88
232
609
1596
4180
10945
28656
75024
196417
99999999
702476551
9999999
395293026
*/

2017 ACM/ICPC Asia Regional Shenyang Online number number number的更多相关文章

  1. 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路

    transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 132768/1 ...

  2. 2017 ACM/ICPC Asia Regional Shenyang Online:number number number hdu 6198【矩阵快速幂】

    Problem Description We define a sequence F: ⋅ F0=0,F1=1;⋅ Fn=Fn−1+Fn−2 (n≥2). Give you an integer k, ...

  3. 2017 ACM/ICPC Asia Regional Shenyang Online E number number number 题解

    分析: 当n=1时ans=4=f(5)-1; n=2,ans=12=f(7)-1; n=3,ans=33=f(9)-1; 于是大胆猜想ans=f(2*k+3)-1. 之后用矩阵快速幂求解f(n)即可, ...

  4. 2017 ACM/ICPC Asia Regional Shenyang Online(部分题解)

    HDU 6197 array array array 题意 输入n和k,表示输入n个整数和可以擦除的次数k,如果至多擦除k次能是的数组中的序列是不上升或者是不下降序列,就是魔力数组,否则不是. 解题思 ...

  5. 2017 ACM/ICPC Asia Regional Shenyang Online cable cable cable

    Problem Description Connecting the display screen and signal sources which produce different color s ...

  6. 2017 ACM/ICPC Asia Regional Shenyang Online

    cable cable cable Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. HDU 6205(尺取法)2017 ACM/ICPC Asia Regional Shenyang Online

    题目链接 emmmm...思路是群里群巨聊天讲这题是用尺取法.....emmm然后就没难度了,不过时间上3000多,有点.....盗了个低配本的读入挂发现就降到2800左右, 翻了下,发现神犇Clar ...

  8. HDU 6198(2017 ACM/ICPC Asia Regional Shenyang Online)

    思路:找规律发现这个数是斐波那契第2*k+3项-1,数据较大矩阵快速幂搞定.   快速幂入门第一题QAQ #include <stdio.h> #include <stdlib.h& ...

  9. 2017 ACM/ICPC Asia Regional Shenyang Online array array array

    2017-09-15 21:05:41 writer:pprp 给出一个序列问能否去掉k的数之后使得整个序列不是递增也不是递减的 先求出LIS,然后倒序求出最长递减子序列长度,然后判断去k的数后长度是 ...

随机推荐

  1. GridView有用的小方法--2017年2月13日

    原文:http://blog.csdn.net/21aspnet/article/category/285354更多:http://blog.csdn.net/21aspnet/article/cat ...

  2. 【LeetCode】020. Valid Parentheses

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...

  3. Java中CountDownLatch类的使用

    0.CountDownLatch作用 1) Java api中的解释:一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待. 2) CountDownLatch可以使J ...

  4. 安装mariadb并修改配置文件

    实验环境:CentOS7 #安装mariadb-server包#修改mariadb配置文件/etc/my.cnf.d/server.cnf#添加 skip_name_resolve=ON #不执行将I ...

  5. day02 秘钥生成,免密访问命令

    hadoop免密登陆: 生成秘钥: ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa cat ~/.ssh/id_dsa.pub >> ~/.ssh/aut ...

  6. cisco 2901 配置拨号上网

    1.输入en,然后输入密码确认后按conf t2.Router(config)# vpdn enable        interface dialer 1   // 进入拨号器13.Router(c ...

  7. [poj3259]Wormholes(spfa判负环)

    题意:有向图判负环. 解题关键:spfa算法+hash判负圈. spfa判断负环:若一个点入队次数大于节点数,则存在负环.  两点间如果有最短路,那么每个结点最多经过一次,这条路不超过$n-1$条边. ...

  8. 报错:defined for 'courierAction_pageQuery' in namespace '/'Error creating bean with name 'cn.itcast.bos.web.action.base.CourierAction': Injection of autowired dependencies failed; nested exception is or

    No qualifying bean of type [cn.itcast.bos.web.service.base.CourierService] found for dependency: exp ...

  9. Struts2学习第八课 声明式异常处理

    异常处理:exception-mapping元素 exception-mapping元素:配置当前的action的声明式异常处理 exception-mapping元素有两个属性: --excepti ...

  10. 9.CVE-2016-5195(脏牛)内核提权漏洞分析

    漏洞描述: 漏洞编号:CVE-2016-5195 漏洞名称:脏牛(Dirty COW) 漏洞危害:低权限用户利用该漏洞技术可以在全版本Linux系统上实现本地提权 影响范围:Linux内核>=2 ...