number number number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 118    Accepted Submission(s): 79

Problem Description

We define a sequence F:

⋅ F0=0,F1=1;
⋅ Fn=Fn−1+Fn−2 (n≥2).

Give you an integer k, if a positive number n can be expressed by
n=Fa1+Fa2+...+Fak where 0≤a1≤a2≤⋯≤ak, this positive number is mjf−good. Otherwise, this positive number is mjf−bad.
Now, give you an integer k, you task is to find the minimal positive mjf−bad number.
The answer may be too large. Please print the answer modulo 998244353.

 

Input

There are about 500 test cases, end up with EOF.
Each test case includes an integer k which is described above. (1≤k≤109)
 

Output

For each case, output the minimal mjf−bad number mod 998244353.
 

Sample Input

1
 

Sample Output

4
 

Source

 
ans = F(2*n+1)-1
 
 //2017-09-10
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 100 using namespace std; const int MOD = ; struct Matrix
{
LL a[MAXN][MAXN];
int r, c;
}; Matrix ori, res; void init()
{
memset(res.a, , sizeof(res.a));
res.r = ; res.c = ;
for(int i = ; i <= ; i++)
res.a[i][i] = ;
ori.r = ; ori.c = ;
ori.a[][] = ori.a[][] = ori.a[][] = ;
ori.a[][] = ;
} Matrix multi(Matrix x, Matrix y)
{
Matrix z;
memset(z.a, , sizeof(z.a));
z.r = x.r, z.c = y.c;
for(int i = ; i <= x.r; i++)
{
for(int k = ; k <= x.c; k++)
{
if(x.a[i][k] == ) continue;
for(int j = ; j<= y.c; j++)
z.a[i][j] = (z.a[i][j] + (x.a[i][k] * y.a[k][j]) % MOD) % MOD;
}
}
return z;
}
void Matrix_mod(int n)
{
while(n)
{
if(n & )
res = multi(ori, res);
ori = multi(ori, ori);
n >>= ;
}
printf("%lld\n", res.a[][]- % MOD);
} int main()
{
int k;
while(scanf("%d", &k) != EOF)
{
init();
k++;
Matrix_mod(*k+);
}
return ;
}

最新文章

  1. redis3.0配置文件详解
  2. Oracle RMAN 恢复控制文件到指定的路径
  3. opencl初体验
  4. SharePoint:WebPartPageUserException This page has encountered a critical error
  5. 读书笔记——Windows核心编程(8)Interlocked单向链式栈
  6. 烂泥:KVM中安装Windows Server 2008 R2系统
  7. Dynamics AX Bitmap to Image File
  8. Transaction &#39;IREG&#39;, Abend &#39;APCT&#39;, at &#39;????&#39;.
  9. 将项目初始化到git服务器
  10. BS_OWNERDRAW风格的作用和例子,值得研究~
  11. E. Riding in a Lift(Codeforces Round #274)
  12. CSS3动画效果之animation
  13. MySQL安装时MySQL server一直安装失败日志显示This application requires Visual Studio 2013 Redistributable
  14. Greendao 缓存问题
  15. scrapy 中间件
  16. kafka 数据存储结构+原理+基本操作命令
  17. vs2010中关于HTML控件与服务器控件分别和js函数混合使用的问题
  18. 使用python实现用微信远程控制电脑
  19. Action(8):Error -27728:Step download timeout(120 seconds)has expired when downloading
  20. Python 爬虫批量下载美剧 from 人人影视 HR-HDTV

热门文章

  1. 转---谈谈HTTP协议中的短轮询、长轮询、长连接和短连接
  2. Swift5 语言参考(四) 表达式
  3. datatable插件使用小记
  4. ProxySQL 部署 Single Writer Failover 读写分离 (PXC)
  5. vue教程1-03 v-for循环
  6. odoo开发笔记:抛出警告的方式
  7. 阿里Java开发规范&amp;谷歌Java开发规范&amp;华为Java开发规范&amp;Tab键和空格比较&amp;Eclipse的Tab键设置 总结
  8. Android初识Helloworld
  9. Choose GitLab for your next open source project
  10. Android开发艺术探索学习笔记(十)