A. Cookies
2016-02-16 13:34
295 查看
A. Cookies
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size,
divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be
equal to the area occupied by one cookie k in size. Fangy also has a box with a square base 2n × 2n,
divided into blocks 1 × 1 in size. In a box the cookies should not overlap, and they should not be turned over or rotated. See cookies of sizes 2 and 4 respectively
on the figure:
To stack the cookies the little walrus uses the following algorithm. He takes out of the repository the largest cookie which can fit in some place in the box and puts it there. Everything could be perfect but alas, in the repository the little walrus has infinitely
many cookies of size 2 and larger, and there are no cookies of size 1,
therefore, empty cells will remain in the box. Fangy wants to know how many empty cells will be left in the end.
Input
The first line contains a single integer n (0 ≤ n ≤ 1000).
Output
Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.
Sample test(s)
input
output
Note
If the box possesses the base of 23 × 23 (as
in the example), then the cookies will be put there in the following manner:
这个题目刚开始错了N遍,原因就
是没有读懂题意, The answer should be printed modulo 106 + 3.这句话是个关键,就是对每个结果取余数,懂了这个,这个题就没啥难的了。
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size,
divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be
equal to the area occupied by one cookie k in size. Fangy also has a box with a square base 2n × 2n,
divided into blocks 1 × 1 in size. In a box the cookies should not overlap, and they should not be turned over or rotated. See cookies of sizes 2 and 4 respectively
on the figure:
To stack the cookies the little walrus uses the following algorithm. He takes out of the repository the largest cookie which can fit in some place in the box and puts it there. Everything could be perfect but alas, in the repository the little walrus has infinitely
many cookies of size 2 and larger, and there are no cookies of size 1,
therefore, empty cells will remain in the box. Fangy wants to know how many empty cells will be left in the end.
Input
The first line contains a single integer n (0 ≤ n ≤ 1000).
Output
Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.
Sample test(s)
input
3
output
9
Note
If the box possesses the base of 23 × 23 (as
in the example), then the cookies will be put there in the following manner:
这个题目刚开始错了N遍,原因就
是没有读懂题意, The answer should be printed modulo 106 + 3.这句话是个关键,就是对每个结果取余数,懂了这个,这个题就没啥难的了。
#include <cstdio> #include <cmath> #include <algorithm> int main() { int a; long long x[1002]; x[0]=1; x[1]=1;x[2]=3; for (int number1=3;number1<1002;number1++) { x[number1]=x[number1-1]*3%(1000000+3); } while(scanf("%d",&a)!=EOF) { printf("%d\n",x[a]); } return 0; }
相关文章推荐
- android:launchMode
- 【SPOJ-WACHOVIA】Wachovia Bank【01背包】
- C#反射的运用
- 跟我学数据结构之栈和队列
- Thinkpad x250安装Windows10后指纹识别的问题
- 杭电1212Big Number(同余定理)
- Samba文件共享服务安装篇
- 百度地图黑屏问题
- run time
- 如何通过后台代码获取map类型如下所示的数据:
- 预留问题待解决
- Ubuntu14.04下安装arm-linux-gcc错误提示
- android的listView如何添加一个ViewPager
- p12转pem
- APP测试功能点总结
- Nginx安装配置篇(Session共享)
- webbench安装篇
- 设计模式六大原则
- iOS开发-文件管理
- IIS上的web service调用AX服务问题