A. Cookies
来源:互联网 发布:非农数据时间 编辑:程序博客网 时间:2024/06/08 07:17
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.
The first line contains a single integer n (0 ≤ n ≤ 1000).
Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.
3
9
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,即面积大小为2^n*2^n时,剩下的空格数正好为3n。 当然,如果超过了10^6+3,就要取余数。
#include <iostream>#include<algorithm>#include<cstdio>#include<cmath>#include<cstring>#include<cstdlib>using namespace std;int main(){int n,i,u=1;scanf("%d",&n);for(i=1;i<n;i++){u*=3;u%=1000003;}printf("%d\n",u);return 0;}
- A. Cookies
- A. Cookies
- A. Cookies
- A Cgi Set Cookies
- A Cgi Get Cookies
- CodeForces 70A Cookies
- 【找规律】#64 A. Cookies
- CodeForces NO.70A Cookies
- Codeforces Gym 100340A Cookies
- Codeforces GYM 100340A Cookies
- jQuery & Cookies (get/set/delete & a plugin)
- Codeforces 129A-Cookies(暴力)
- cookies
- Cookies
- Cookies
- Cookies
- Cookies
- Cookies
- C++中需要注意的细节
- Emgu CV库:.net平台下对openCV图像处理库的封装
- Python程序的性能分析指南
- inotify -- Linux 2.6 内核中的文件系统变化通知机制
- Linux中grep命令的用法
- A. Cookies
- java 字体颜色转换工具类 ColorUtil
- 常见经典排序算法
- php匹配的一些函数
- error LNK2026:模块对于 SAFESEH 映像是不安全的
- C#将图像存成视频
- 管理学经典定理之一
- 浏览器获取EVENT的方法
- i9100指令代码