1018: Give me the answer
1018: Give me the answer
时间限制: 1 Sec 内存限制: 32 MB
提交: 55 解决: 15
[提交][状态][讨论版][命题人:外部导入]
题目描述
输入
输出
For each test case, output a line with the ans % 1000000000.
样例输入
1
7
样例输出
6
#include<stdio.h>
#define MAX 1000010
int a[MAX];
int main()
{
int n, m, i;
a[1] = 1;
a[2] = 2;
for(i = 3; i <= MAX; ++i)
{
if(i & 1)
a[i] = a[i - 1] % 1000000000;
else
a[i] = (a[i - 1] + a[i / 2]) % 1000000000;
}
scanf("%d", &n);
while(n--)
{
scanf("%d", &m);
printf("%d\n", a[m]);
}
return 0;
}
1018: Give me the answer的更多相关文章
- CodeForces - 662A:Gambling Nim (求有多少个子集其异或为S)(占位)
As you know, the game of "Nim" is played with n piles of stones, where the i-th pile initi ...
- Codeforces Round #565 (Div. 3) A
A. Divide it! 题目链接:http://codeforces.com/contest/1176/problem/A 题目 You are given an integer n You ca ...
- A - Divide it! CodeForces - 1176A
题目: You are given an integer nn. You can perform any of the following operations with this number an ...
- CodeForces - 1176A Divide it! (模拟+分类处理)
You are given an integer nn. You can perform any of the following operations with this number an arb ...
- Codeforces1176A(A题)Divide it!
Divide it! You are given an integer nn. You can perform any of the following operations with this nu ...
- GSS4 - Can you answer these queries IV(线段树懒操作)
GSS4 - Can you answer these queries IV(线段树懒操作) 标签: 线段树 题目链接 Description recursion有一个正整数序列a[n].现在recu ...
- 【LEETCODE】53、数组分类,简单级别,题目:989、674、1018、724、840、747
真的感觉有点难... 这还是简单级别... 我也是醉了 package y2019.Algorithm.array; import java.math.BigDecimal; import java. ...
- SPOJ GSS3 Can you answer these queries III[线段树]
SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...
- PAT A 1018. Public Bike Management (30)【最短路径】
https://www.patest.cn/contests/pat-a-practise/1018 先用Dijkstra算出最短路,然后二分答案来验证,顺便求出剩余最小,然后再从终点dfs回去求出路 ...
随机推荐
- Problem02 输出素数
题目:判断101-200之间有多少个素数,并输出所有素数. 程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,则表明此数不是素数,反之是素数. public class ...
- shell中的命令与特殊符号
1.记录命令:! !!:连续的“!”表示执行上一次的指令 !n:表示执行命令历史中第二条指令 注:!2居然给我关机了 !字符串(字符串大于1)表示执行命令历史中最近的一次 2.通配符 " * ...
- 转Linux 下用alias 设置命令别名快速切换常用命令
https://blog.csdn.net/u012830148/article/details/80618616 在linux下开发,经常需要切换目录,如果目录很长则切换起来非常的麻烦,针对一些常用 ...
- Serializable深入理解
1.什么是序列化,解决什么问题 序列化可以对象的状态信息转换成可以持久化或者可以传输形式的过程.一般是转为字节数据.而把字节数组还原成原来同等对象的过程成为反序列化. 在Java中,对象的序列化与反序 ...
- nodejs的异步非阻塞IO
简单表述一下:发启向系统IO操作请求,系统使用线程池IO操作,执行完放到事件队列里,node主线程轮询事件队列,读取结果与调用回调.所以说node并非真的单线程,还是使用了线程池的多线程. 上个图看看 ...
- sql查询约束
写作业的时候发现书上竟然找不到查询约束的语句,百度搜了好久的资料,终于查询成功,在这里记录下来 主键约束 SELECT tab.name AS [表名], idx.name AS [主键名称] ...
- DB Intro - MySQL and MongoDB
mysql> CREATE TABLE tutorials_tbl( tutorial_id INT, tutorial_title VARCHAR(100), tutorial_author ...
- 【Linux】Debian 8 设置命令行界面的文本颜色
平时我们操作的系统命令行界面文本默认黑底白字,有时候会看不惯这种全篇都是白色字符,这个时候可以通过改变PS1环境变量来改变文本颜色.我个人喜欢黑底绿字的搭配,以下是我个人的命令行界面样式: 注意:以下 ...
- Prestashop后台模块(中英转译)
=======================Prestashop-Modules========================= Pretashop运行起来非常慢,这个大家应该都知道,最近要给这个 ...
- python 字符串转字节数组
场景: java加解密和python加解密互转的时候,因一些非显示字符无法确认两者是否一致,故需要打出他们的十六进制字节数组进行比较 1.python代码实现 str='123';print str. ...