poj 1806 分块模拟
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 1318 | Accepted: 703 |
Description
Input
Output
- the digits 0 to 9 for intersections in the range, representing the amount of petrol necessary to go there,
- and the dot "." for intersections not in the range.
Print an additional blank line after each scenario.
Sample Input
2
0
2
Sample Output
Scenario #1:
slice #1:
0 Scenario #2:
slice #1:
.....
.....
..2..
.....
.....
slice #2:
.....
..2..
.212.
..2..
.....
slice #3:
..2..
.212.
21012
.212.
..2..
slice #4:
.....
..2..
.212...2.. ..... slice #5: ..... ..... ..2.. ..... .....
Source
#include <stdio.h>
#include <string.h>
#include <stdlib.h> int Scenario,Oil,Slice,M[][];
void Display()
{
int i,j;
for (i=;i<Slice;i++)
{
for (j=;j<Slice;j++)
{
if (M[i][j]<=Oil)
printf("%d",M[i][j]);
else
printf(".");
}
printf("\n");
}
}
void left_up(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
left_up(x-,y,m+t,t);
left_up(x,y-,m+t,t); }
void up_right(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
up_right(x+,y,m+t,t);
up_right(x,y-,m+t,t);
}
void right_down(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
right_down(x+,y,m+t,t);
right_down(x,y+,m+t,t); }
void down_left(int x,int y,int m,int t)
{
if (m==Oil+)
return;
M[x][y]=m;
down_left(x,y+,m+t,t);
down_left(x-,y,m+t,t);
}
void func(int x,int y,int m,int t)
{
left_up(x,y,m,t);
up_right(x,y,m,t);
right_down(x,y,m,t);
down_left(x,y,m,t);
}
int main()
{
int i,j,x,y;
scanf("%d",&Scenario);
for(i=;i<=Scenario;i++)
{
scanf("%d",&Oil);
printf("Scenario #%d:\n",i);
if (Oil==)
{
printf("slice #1:\n0\n");
}
else
{
Slice=*Oil+;
for (j=;j<Slice;j++)
{
memset(M,,sizeof(M));
x=Oil;
y=Oil;
printf("slice #%d:\n",j+);
if (j<=Oil)
func(x,y,Oil-j,);
else
func(x,y,j-Oil,);
Display();
}
}
printf("\n");
}
return ;
}
注意方位的把握~~~
poj 1806 分块模拟的更多相关文章
- P1972 [SDOI2009]HH的项链[离线+树状数组/主席树/分块/模拟]
题目背景 无 题目描述 HH 有一串由各种漂亮的贝壳组成的项链.HH 相信不同的贝壳会带来好运,所以每次散步完后,他都会随意取出一段贝壳,思考它们所表达的含义.HH 不断地收集新的贝壳,因此,他的项链 ...
- poj 3077Rounders(模拟)
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063? viewmode=contents 题目链接:http://po ...
- POJ 1068 Parencodings 模拟 难度:0
http://poj.org/problem?id=1068 #include<cstdio> #include <cstring> using namespace std; ...
- POJ 1036 Rails 模拟堆栈
水题,主要是思路清晰,判断明确. 记x为A站最前方的车,y表示下一列要进入B站的车厢,初识时,x=1;y=a1;C=[]; 在调度过程中: if(y==0)那么调度成功,退出模拟过程:否则 if(x= ...
- POJ 1001 Exponentiation 模拟小数幂
模拟小数幂 小数点位 pos 非零末位 e 长度 len 只有三种情况 pos > len pos < e e < pos < len #include <iostrea ...
- A Simple Problem with Integers POJ - 3468 (分块)
题目链接:https://cn.vjudge.net/problem/POJ-3468 题目大意:区间加减+区间查询操作. 具体思路:本来是一个线段树裸题,为了学习分块就按照分块的方法做吧. 分块真的 ...
- POJ 1008 简单模拟题
e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...
- poj 1806 Frequent values(RMQ 统计次数) 详细讲解
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1806 题目大意:给你一个非降序排列的整数数组,你的任务是对于一系列的询问,(i,j),回答序列中出现次 ...
- Crashing Robots POJ 2632 简单模拟
Description In a modernized warehouse, robots are used to fetch the goods. Careful planning is neede ...
随机推荐
- TP框架,根据当前应用状态对应的配置文件
index.php define('APP_STATUS','website'); /ThinkPHP/Library/Think/Dispatcher.class.php /** * 应用程序初始化 ...
- Javascript.ReactNative-2-javascript-syntax-in-react-native
JavaScript Syntax in React Native Contents: Arrow Function Let+Const Default + Rest + Spread Destruc ...
- 【转载】SQL Server 2008 r2 中 SQL语句中单引号转义
sql server有两个转义符. 默认情况下, 单引号'是字符串的边界符, 如果在字符串中包含单引号', 则必须使用两个单引号', 第1个单引号'就是转义符.
- php框架制做笔记
在学习完基础之后,最好的提高方式是做一个自己的框架,因为框架会用到各个知识点,在制做过程中,复习,巩固,提高. 在框架中,因为是单入口,整个脚本运行时都存在的变量我们应该设为静态变量,这样它在每个地方 ...
- android开发学习笔记000
使用书籍:<疯狂android讲义>——李刚著,2011年7月出版 虽然现在已2014,可我挑来跳去,还是以这本书开始我的android之旅吧. “疯狂源自梦想,技术成就辉煌.” 让我这个 ...
- Shell使用技巧
巧用定界符delimiter 输入大段文本的地方 自动选择和输入的地方 访问数据库 Angel@DESKTOP-254LBLA ~ $ cat > out.txt << EOF &g ...
- Trie 最长前缀匹配串的实现
http://blog.csdn.net/hguisu/article/details/8131559
- MMS彩信字符集(字符编码)
彩信字符集在CharacterSets类中定义 android\frameworks\opt\telephony\src\java\com\google\android\mms\pdu\Charact ...
- 设计模型MVC和JavaBean
六.设计模型1和设计模型2(MVC)1.模型1:JSP+JavaBean2.模型2:MVC M:Model模型 JavaBean V:视图 JSP C:控制器 Servlet 七.模型1开发一个简单的 ...
- I/O知识
1.jdk1.4之前(jdk1.4开始提供了nio)的早起版本,java对I/O的支持并不完善,开发人员开发高性能I/O程序时,面临的问题主要有: 没有缓冲区,I/O性能存在问题 没有 ...