A - Fox And Snake

Problem description

Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.

A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r,?c). The tail of the snake is located at (1,?1), then it‘s body extends to (1,?m), then goes down 2 rows to (3,?m), then goes left to (3,?1) and so on.

Your task is to draw this snake for Fox Ciel: the empty cells should be represented as dot characters (‘.‘) and the snake cells should be filled with number signs (‘#‘).

Consider sample tests in order to understand the snake pattern.

Input

The only line contains two integers: n and m (3?≤?n,?m?≤?50).

n is an odd number.

Output

Output n lines. Each line should contain a string consisting of m characters. Do not output spaces.

Examples

Input

3 3

Output

###..####

Input

3 4

Output

####...#####

Input

5 3

Output

###..#####..###

Input

9 9

Output

#########........###########........#########........###########........#########解题思路:按规律输出,当i为奇数时,输出的一行全部为‘#‘;当i为偶数时,用flag做开关,交换输出两种格式,水过!AC代码:
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define FOR(a,b,c) for(int i=a;i<=b;++i)printf("%c",c)
 4 int n,m;bool flag;
 5 int main(){
 6     cin>>n>>m;flag=false;
 7     for(int i=1;i<=n;++i){
 8         if(i%2)FOR(1,m,‘#‘);
 9         else{
10             if(!flag){FOR(1,m-1,‘.‘);cout<<‘#‘;flag=true;}
11             else{cout<<‘#‘;FOR(2,m,‘.‘);flag=false;}
12         }
13         cout<<endl;
14     }
15     return 0;
16 }

原文地址:https://www.cnblogs.com/acgoto/p/9191968.html

时间: 2024-10-15 21:17:02

A - Fox And Snake的相关文章

CodeForces 510 A. Fox And Snake(模拟啊 )

题目链接:http://codeforces.com/problemset/problem/510/A Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead. A snake is a pattern on a n by m

Codeforces Round #290 (Div. 2) 解题报告 A.B.C.D.

A - Fox And Snake 模拟. 代码如下: #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <stdlib.h> #include <map> #include <set> #include <stdio.h> using na

CodeForces 388A Fox and Box Accumulation 贪心

Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel cann

Active Snake (Level Set 模型)

前沿:最近由于大论文实验的原因,需要整理几种Snake方法,以比较道路提取效果.所以今天晚上就将电脑中的一些LBF Snake代码作一下分类定义.并给出效果.以便比较. 1. 原始的LBF Snake方法的效果 原始的LBF算法实现如下: 实验的代码下载地址,Download Link.然后在网盘中找到这个目录,然后找到下图所示的文件. 但是,初步测试是不能用,原因是LSE程序的源文件无法编译,找不到源文件.这个代码中提到的参考文献是[1]. 如果需要更加详细的学习,请直接百度学术中下载. 一下

Codeforces Round #290 (Div. 2) C. Fox And Names 拓扑排序

C. Fox And Names time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: t

CodeForces510 C. Fox And Names(拓扑排序)

题目链接:http://codeforces.com/problemset/problem/510/C C. Fox And Names time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer S

CodeForces 510 B. Fox And Two Dots(DFS 啊)

题目链接:http://codeforces.com/problemset/problem/510/B Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n?×?m cells, like this: Each cell contains a dot that has some color. We will use diff

网络流(最大流)CodeForces 512C:Fox And Dinner

Fox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old. They will have dinner around some round tables. You want to distribute foxes such that: Each fox is sitting at some table

UVaLive 6581 &amp;&amp; Gym 100299B What does the fox say? (模拟+STL)

题意:给定一些动物的叫声,然后再定某些动物的叫声,让你去除这些叫声后得到的叫声. 析:先存储所有的叫声,然后用map来记录其他的叫声,在输出时再判定一下就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #includ