HDOJ/HDU 1256 画8(绞下思维~水题)

Problem Description
谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发.

Input
输入的第一行为一个整数N,表示后面有N组数据.
每组数据中有一个字符和一个整数,字符表示画笔,整数(>=5)表示高度.

Output
画横线总是一个字符粗,竖线随着总高度每增长6而增加1个字符宽.当总高度从5增加到6时,其竖线宽度从1增长到2.下圈高度不小于上圈高度,但应尽量接近上圈高度,且下圈的内径呈正方形.
每画一个”8”应空一行,但最前和最后都无空行.

Sample Input
2
A 7
B 8

Sample Output

  AA
AA  AA
AA  AA
  AA
AA  AA
AA  AA
  AA

  BBB
BB   BB
BB   BB
  BBB
BB   BB
BB   BB
BB   BB
  BBB

水题。。多想想就出来了。

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int f=0;
        while (t-- > 0) {
            String s = sc.next();
            int n = sc.nextInt();
            if (f!=0) {
                System.out.println();
            }
            int m = (int) n / 6 + 1;
            // System.out.println(m);//m+2
            int h = n - 3;
            h = h / 2 + 1;
            int p=h;
            if(n%2!=0){
                h--;
            }
            for (int i = 0; i < n; i++) {
                if (i == 0 || i == n - 1 || i == p) {
                    for (int k = 0; k < m + h; k++) {
                        if (k < m) {
                            System.out.print(" ");
                        } else {
                            System.out.print(s);
                        }
                    }
                    System.out.println();
                } else {
                    for (int k = 0; k < 2 * m + h; k++) {
                        if (k < m || k >= m + h) {
                            System.out.print(s);
                        } else {
                            System.out.print(" ");
                        }
                    }
                    System.out.println();
                }
            }
            f=1;
        }
    }
}
时间: 2024-08-25 18:34:04

HDOJ/HDU 1256 画8(绞下思维~水题)的相关文章

HDOJ(HDU) 2061 Treasure the new start, freshmen!(水题、)

Problem Description background: A new semester comes , and the HDU also meets its 50th birthday. No matter what's your major, the only thing I want to tell you is:"Treasure the college life and seize the time." Most people thought that the colle

HDOJ(HDU) 1898 Sempr == The Best Problem Solver?(水题、、、)

Problem Description As is known to all, Sempr(Liangjing Wang) had solved more than 1400 problems on POJ, but nobody know the days and nights he had spent on solving problems. Xiangsanzi(Chen Zhou) was a perfect problem solver too. Now this is a story

HDU 1256 画8

画8 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 2   Accepted Submission(s) : 2 Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发.   Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一个整数,字符表示画笔,

HDOJ(HDU) 2500 做一个正气的杭电人(水~)

Problem Description 做人要有一身正气,杭电学子都应该如此.比如我们今天的考试就应该做到"诚信"为上. 每次考试的第一个题目总是很简单,今天也不例外,本题是要求输出指定大小的"HDU"字符串,特别地,为了体现"正气"二字,我们要求输出的字符串也是正方形的(行数和列数相等). Input 输入的第一行包含一个正整数N(N<=20),表示一共有N组数据,接着是N行数据,每行包含一个正整数M(M<=50),表示一行内有M个

HDOJ(HDU) 2107 Founding of HDU(找最大值)

Problem Description 经过慎重的考虑,XHD,8600, LL,Linle以及RPG等ACM队员集体退役,甚至正在酝酿退学. 为什么?要考研?那也不用退学呀- 当然不是!真正的原因是他们想提前创业,想合伙成立一家公司,据说公司的名称都想好了,为了感谢多年的ACM集训队队长XHD,公司就叫海东集团(HaiDong Union),简称HDU.(对于这个公司名称,几个人私下里开玩笑说,外面的人看到HDU,可别以为是"胡捣集团",呵呵) 公司成立了,谁来做老大呢?这对于合伙的

HDOJ(HDU) 1491 Octorber 21st

Problem Description HDU's 50th birthday, on Octorber 21st, is coming. What an exciting day!! As a student of HDU, I always want to know how many days are there between today and Octorber 21st.So, write a problem and tell me the answer.Of course, the

java-Java基础题大牛们给解决下,基础题大道理。

问题描述 Java基础题大牛们给解决下,基础题大道理. 设有整形变量a和b的值分别为5和110.试指出执行了以下循环语句后,变量x和y的值分别是多少? while(x<=y)x *=2; 这是一道课本上的题,看了半天也没看清楚说了什么...还望大神们给解释解释... 解决方案 你指的a和b是 X和Y吧! 这句话的意思就是 当x { 让X=X×2;也就是让X变为原来的2倍,只要X得到的值小于Y,那么就继续这个循环,:也就是说当X=5,Y=110时,我们要执行循环 5×2×2×2×2×2 = 160

HDOJ(HDU) 2192 MagicBuilding(用Java的Map做了下)

Problem Description As the increase of population, the living space for people is becoming smaller and smaller. In MagicStar the problem is much worse. Dr. Mathematica is trying to save land by clustering buildings and then we call the set of buildin

HDOJ(HDU) 2133 What day is it(认识下Java的Calendar类---日期类)

Problem Description Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me what day it is ? Input There are multiply cases. One line is one case. There are three integers, year(0< year<10000), month(0<=month<13), day(0<