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回去求出路 ...
随机推荐
- 技巧:Python中print打印信息的同时打印文件、行号
import sys def Log(msg): print('Print Message: '+msg+' ,File: "'+__file__+'", Line '+str(s ...
- Should I buy Auro OtoSys IM600 or Obdstar X300 DP?
Auro OtoSys IM600 and Obdstar X300 DP – What’s the difference & Which better? This is for those ...
- 第一章javascript简介
javascript 当诞生于1995 最开始是目的是处理在服务器端进行的表单验证:让其在服务器端验证改为在服务端验证,大大提高速度(当时网络慢) 如今javascript是一门功能全面的语言,包含闭 ...
- 结合element-ui表格自动生成sku规格列表
最近在写一个根据输入的规格,属性值动态生成sku表格,实现的效果大致如图,这是在vue项目里,结合element-UI表格写的,写好了就整理了一下,把代码贴上来,方便以后使用,不过代码里还是有一些重复 ...
- java——二分搜索树 BST(递归、非递归)
~ package Date_pacage; import java.util.Stack; import java.util.ArrayList; import java.util.LinkedLi ...
- win10重装完登录不了微软账号
in10重装完登录不了微软账号解决方法如下: 点击win键+R,然后输入services.msc回车,进入本地服务管理,查看以下服务是否正常启用了: Microsoft Account Sign-in ...
- DataFrame的数据类型转换
dfxxx['username']=pd.to_numeric(dfxxx['username'],errors='coerce')#将不能转换数据类型的值强制转换成NaN dfxxx['userna ...
- Linux下wget下载软件小技巧以及安装jdk、tomcat与ftp服务器
一.ftp的安装 装个ftp搞了一下午,感觉以前没那么麻烦的呀,结果到晚上才发现是实验室网的问题,换连手机的热点马上可以了,真是尴尬,把基本安装步骤记录一下: 1.检查安装vsftpd软件 使用如下命 ...
- Kure讲HTML_列表标签及表单标签
首先我上个图来告诉大家什么是列表 左侧的这一部分就可以称为是列表或者叫树,其实我们可以通过div+css实现列表,可是考虑语义化的问题,我们还是看看html提供好的列表标签,html提供了两种列表,一 ...
- linux_api之文件操作
本篇索引: 1.引言 2.文件描述符 3.open函数 4.close函数 5.read函数 6.write函数 7.lseek函数 8.i/o效率问题 9.内核用以维护打开文件的相关数据结构 10. ...