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代码:
#include<bits/stdc++.h>
using namespace std;
#define FOR(a,b,c) for(int i=a;i<=b;++i)printf("%c",c)
int n,m;bool flag;
int main(){
cin>>n>>m;flag=false;
for(int i=;i<=n;++i){
if(i%)FOR(,m,'#');
else{
if(!flag){FOR(,m-,'.');cout<<'#';flag=true;}
else{cout<<'#';FOR(,m,'.');flag=false;}
}
cout<<endl;
}
return ;
}
A - Fox And Snake的更多相关文章
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces 510 A.Fox and Snake
题目链接:http://codeforces.com/contest/510/problem/A A. Fox And Snake time limit per test2 seconds memor ...
- 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake
题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...
- 【codeforces 510A】Fox And Snake
[题目链接]:http://codeforces.com/contest/510/problem/A [题意] 让你画一条蛇.. [题解] 煞笔提 [Number Of WA] 0 [完整代码] #i ...
- CodeForces Round #290 Div.2
A. Fox And Snake 代码可能有点挫,但能够快速A掉就够了. #include <cstdio> int main() { //freopen("in.txt&quo ...
- [LeetCode] Design Snake Game 设计贪吃蛇游戏
Design a Snake game that is played on a device with screen size = width x height. Play the game onli ...
- Leetcode: Design Snake Game
Design a Snake game that is played on a device with screen size = width x height. Play the game onli ...
- [DFNews] Fire-Eye与Fox IT联合推出Cryptolocker解锁网站
Cryptolocker是臭名昭著的勒索程序,使用AES加密后密钥回传,用户除了缴纳赎金之外基本无法解密数据. 近日,知名安全公司Fire-Eye与Fox IT联合推出了针对该勒索程序的解锁网站 ht ...
- 在线教学、视频会议 Webus Fox(1)文本、语音、视频聊天及电子白板基本用法
Webus Fox是基于网页的在线教学.视频会议软件,不用安装,直接使用.它提供文本.语音.视频聊天,文件共享.电子白板等功能. 1. 登录 访问 http://flash.webus.cn/#,用自 ...
随机推荐
- nginx设置绑定解析实现二级域名多域名
apache(httpd)配置多个二级域名看这个链接:https://www.cnblogs.com/Crazy-Liu/p/10879928.html 网站的目录结构为/home/www├── bb ...
- js for 循环 添加tr td 算法
StringBuffer sb=new StringBuffer(); int n = 5; sb.append("<tr>"); List<MenuBean&g ...
- codevs——4189 字典&&HihoCoder #1014 : Trie树
题目描述 Description 最经,skyzhong得到了一本好厉害的字典,这个字典里整整有n个单词(1<=n<=200000) 现在skyzhong需要在字典里查询以某一段字母开头的 ...
- Codeforces Round #467 Div.2题解
A. Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Django-----中间件Cookie
Cookie: 用来跟踪用户的会话.常用的会话跟踪技术是Cookie与Session.Cookie通过在客户端记录信息确定用户身份,Session通过在服务器端记录信息确定用户身份. Cookie机制 ...
- 第六节:web爬虫之urllib(二)
二.urllib.request.Request(url, data=None, headers={}, origin_req_host=None, unverifiable=False, metho ...
- 赛门铁克通配符SSL证书,一张通配型证书实现全站加密
赛门铁克通配型SSL证书,验证域名所有权和企业信息,属于企业验证(OV) 级SSL证书,最高支持256位加密.申请通配符SSL证书可以保护相同主域名下无限数量的多个子域名(主机).例如,一个通配符 ...
- POJ 1821 Fence
Fence Time Limit: 1000ms Memory Limit: 30000KB This problem will be judged on PKU. Original ID: 1821 ...
- Spring Cloud 之 Cookie 丢失 与 Host 传递
通过spring zuul 代理至后台,写入Cookie发现无法写入,到浏览器中,和无法获取Domain域名 通过长时间的度娘和求助别人发现:Spring-zuul 需要加入以下配置 zuul.se ...
- Color the ball 线段树 区间更新但点查询
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #inclu ...