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回去求出路 ...
随机推荐
- Autel MaxiSys Pro MS908P
Autel MaxiSys pro MS908P is an evolutionary smart solution for specialized automotive diagnosis and ...
- The 'gridview' module MUST be setup in your Yii configuration file.
解决方法:common的config的main.php中添加 'gridview' => ['class' => 'kartik\grid\Module'], 在vender的compos ...
- java——利用生产者消费者模式思想实现简易版handler机制
参考教程:http://www.sohu.com/a/237792762_659256 首先说一下这里面涉及到的线程: 1.mainLooper: 这个线程可以理解为消费者线程,里面运行了一个死循环, ...
- JavaSE---多线程---线程的生命周期
1.线程的生命周期:新建.就绪.运行.阻塞.死亡 2.运行状态线程进入阻塞: 1.1 调用sleep方法主动放弃: 1.2 调用线程的suspend方法将线程挂起,不推荐使用: 1.3 线程调用一个阻 ...
- Silverlight 中图片路径的设置
在Silverlight中图片的设置方法有几种 如上图在一个工程中有个images文件夹,buttons.xaml页面中的Image控件要引用一张图片 第一种方法 xaml: <Image x: ...
- DRF-->1 序列化组件的使用和接口设计---get
定义序列化器(本质就是一个类),一般包括模型类的字段,有自己的字段类型规则.实现了序列化器后,就可以创建序列化对象以及查询集进行序列化操作,通过序列化对象.data来获取数据(不用自己构造字典,再返回 ...
- (转)AIX下修改用户最大进程数
AIX下修改用户最大进程数 原文:http://blog.csdn.net/feichideche/article/details/39498555 使用AIX时候,切换用户,发现进程一直挂起,查看用 ...
- 分布式任务框架elastic-job 学习笔记
官方资料:https://github.com/dangdangdotcom/elastic-job ------------------------------------------------- ...
- go语言初始化内部结构体3中方式
package main import ( "fmt" ) type User struct { Id int Name string Age int } type Manger ...
- DEDE用{dede:sql}标签取出当前文档的附加表中的内容
最近在用DEDE做项目,遇到一个需求是要在article_image.htm模板中直接取出附加表addonimages中的某一记录的imgurls字段的内容.而这条记录是不断变化的,比如我点击了< ...