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 ...
随机推荐
- C#实现简单的委托异步调用
delegate void textAsy(); static void Main(string[] args) { textAsy t = texts; AsyncCallback callBack ...
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
1 查看远程分支 $ git branch -a * br-2.1.2.2 master remotes/origin/HEAD -> origin/master remotes/origin/ ...
- [ubuntu] adb devices出现no permissions
简书排版 http://www.jianshu.com/p/46e8848c6646 今天把一款测试的华为手机带回家,发现无法联机调试 笔者操作系统是 ubuntu 14.04 如果是windows找 ...
- ExtJs知识点概述
1.前言 ExtJS的前身是YUI(Yahoo User Interface).经过不断的发展与改进,ExtJS现在已经成功发布到了ExtJS 6版本,是一套目前最完整和最成熟的javascript基 ...
- eclipse中安装adt插件
对于程序开发的学者来说,eclipse并不陌生,它为我们提供了一个非常广阔的平台来开发程序.同样我们也可以用它来开发android程序.但是在eclipse中并不能直接开发android程序,需要我们 ...
- 如何优化sql语句
1. 首先要搞明白什么叫执行计划? 执行计划是数据库根据SQL语句和相关表的统计信息作出的一个查询方案,这个方案是由查询优化器自动分析产生的,比如一条SQL语句如果用来从一个 10万条记录的表中查1条 ...
- jQuery动画特效笔记
show().hide().fadeIn().fadeOut().slideDown.slideUp.slideToggle()都接受可选的时长和回调参数(选项对象参数). toggle(durati ...
- 利用带关联子查询Update语句更新数据
Update是T-sql中再简单不过的语句了,update table set column=expression [where condition],我们都会用到.但update的用法不仅于此,真 ...
- 【转】webGL与OpenGL的不同
原链接 http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences WebGL and OpenGL Differences ...
- 1996: [Hnoi2010]chorus 合唱队
链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1996 Description Input Output Sample Input 4 1701 ...