当前位置:首页 > 历届试题及答案(整理201504)
蓝桥杯软件大赛历届试题及答案
核桃的数量 打印十字图 带分数 剪格子 错误票据 翻硬币 连号区间数 买不到的数目 大臣的旅费 幸运数
横向打印二叉树 危险系数 网络寻路 高僧斗法 格子刷油漆 农场阳光
约数倍数选卡片 九宫重排 公式求值 回文数字 国王的烦恼 数字游戏 邮局 城市建设 最大子阵 蚂蚁感冒 地宫取宝 斐波那契 波动数列 小朋友排队 分糖果 矩阵翻硬币 兰顿蚂蚁
2 2 3 4 5 7 8 8 9 11 12 13 15 16 17 18 18 19 22 24 25 27 27 28 30 31 32 33 34 35 36 37 38
1
核桃的数量
问题描述
小张是软件项目经理,他带领3个开发组。工期紧,打印十字图
问题描述
小明为某机构设计了一个十字型的徽标(并非红十字会啊),如下所示: 今天都在加班呢。为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑)。他的要求是: 1. 各组的核桃数量必须相同
2. 各组内必须能平分核桃(当然是不能打碎的) 3. 尽量提供满足1,2条件的最小数量(节约闹革命嘛) 输入格式
输入包含三个正整数a, b, c,表示每个组正在加班的人数,用空格分开(a,b,c<30) 输出格式
输出一个正整数,表示每袋核桃的数量。 样例输入1 2 4 5
样例输出1 20
样例输入2 3 1 1
样例输出2 3
import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str[] = br.readLine().split(\ int[] arr = new int[3]; for (int a = 0; a < arr.length; a++) { arr[a] = Integer.parseInt(str[a]); } for (int a = 1; a < 27000; a++) { if (a % arr[0] == 0 && a % arr[1] == 0 && a % arr[2] == 0) { System.out.print(a); break; } } } }
..$$$$$$$$$$$$$.. ..$...........$..
$$$.$$$$$$$$$.$$$ $...$.......$...$
$.$$$.$$$$$.$$$.$ $.$...$...$...$.$ $.$.$$$.$.$$$.$.$ $.$.$...$...$.$.$ $.$.$.$$$$$.$.$.$ $.$.$...$...$.$.$ $.$.$$$.$.$$$.$.$ $.$...$...$...$.$ $.$$$.$$$$$.$$$.$ $...$.......$...$
$$$.$$$$$$$$$.$$$ ..$...........$..
..$$$$$$$$$$$$$..
对方同时也需要在电脑dos窗口中以字符的形式输出该标志,并能任意控制层数。 输入格式
一个正整数 n (n<30) 表示要求打印图形的层数。 输出格式
对应包围层数的该标志。 样例输入1 1
样例输出1 ..$$$$$.. ..$...$.. $$$.$.$$$ $...$...$ $.$$$$$.$ $...$...$ $$$.$.$$$ ..$...$.. ..$$$$$.. 样例输入2 3
样例输出2
..$$$$$$$$$$$$$.. ..$...........$..
2
$$$.$$$$$$$$$.$$$ $...$.......$...$
$.$$$.$$$$$.$$$.$ $.$...$...$...$.$ $.$.$$$.$.$$$.$.$ $.$.$...$...$.$.$ $.$.$.$$$$$.$.$.$ $.$.$...$...$.$.$ $.$.$$$.$.$$$.$.$ $.$...$...$...$.$ $.$$$.$$$$$.$$$.$ $...$.......$...$
$$$.$$$$$$$$$.$$$ ..$...........$..
..$$$$$$$$$$$$$..
提示:请仔细观察样例,尤其要注意句点的数量和输出位置。
import java.util.Scanner; public class Main{
public static void main(String[] args){ Scanner sc=new Scanner(System.in); fd(sc.nextInt()); }
public static void fd(int n){ int len=5+4*n;
String a[][]=new String[len][len]; int b=len/2;
for(int i=0;i for(int j=0;j for(int i=b-2;i for(int m=0;m for(int i=b-2-2*m;i<(b+3+2*m);i++){ a[b - (4+m*2)][i] = \ a[b + (4+m*2)][i] = \ a[i][b - (4+m*2)] = \ a[i][b + (4+m*2)] = \ } } for(int m=0;m for (int i = b - (3+m*2); i <= b + 3+m*2; i++) { a[b - (2+m*2)][i] = \ a[b + 2+m*2][i] = \ a[i][b + 2+m*2] = \ a[i][b - (2+m*2)]= \ } a[b - (2+m*2)][b - (1+m*2)] = \ a[b - (2+m*2)][b + 1+m*2] = \ a[b + 2+m*2][b - (1+m*2)] = \ a[b + 2+m*2][b + 1+m*2] = \ a[b - (1+m*2)][b - (2+m*2)] = \ a[b + 1+m*2][b - (2+m*2)] = \ a[b - (1+m*2)][b + 2+m*2] = \ a[b + 1+m*2][b + 2+m*2] = \ } for (int i= 0; i < len; i++) { for (int j = 0; j < len; j++) { System.out.print(a[i][j]); } System.out.println(); } } } 带分数 问题描述 100 可以表示为带分数的形式:100 = 3 + 69258 / 714。 还可以表示为:100 = 82 + 3546 / 197。 注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。 类似这样的带分数,100 有 11 种表示法。 输入格式 从标准输入读入一个正整数N (N<1000*1000) 输出格式 程序输出该数字用数码1~9不重复不遗漏地组成带分数表示的全部种数。 注意:不要求输出每个表示,只统计有多少表示法! 3 样例输入1 100 样例输出1 11 样例输入2 105 样例输出2 6 import java.util.Scanner; /** * http://lx.lanqiao.org/problem.page?gpid=T26 * Created by revintec on 14-5-5. */ public class Main{ static int getBits(int k){ int bits=0; while(k>0){ int a=k;k/=10; if(a==0) return -1; int b=1< if((bits&b)!=0) return -1; bits|=b; }return bits; } static int getBits2(int b){ int lo=9; for(int i=1;i<1<<10;i<<=1) if((b&i)!=0) --lo; return lo; } public static void main(String[] args){ // System.clearProperty(\ Scanner sc=System.getProperty(\Scanner(System.in): new Scanner(\ int sx=sc.nextInt(); int[] ts={0, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, }; int so=0; for(int a=1;a int bts=getBits(b); if((bits&bts)!=0) continue; bts|=bits; long c=b*(sx-a); if(c>=ts[getBits2(bts)]) break; if((getBits((int)c)^bts)==1022) ++so; } }System.out.println(so); } } 剪格子 问题描述 如下图所示,3 x 3 的格子中填写了一些整数。 +--*--+--+ |10* 1|52| +--****--+ |20|30* 1| *******--+ | 1| 2| 3| +--+--+--+ 我们沿着图中的星号线剪开,得到两个部分,每个部分的数字和都是60。 本题的要求就是请你编程判定:对给定的m x n 的格子中的整数,是否可以分割为两个部分,使得这两个区域的数字和相等。 如果存在多种解答,请输出包含左上角格子的那个区域包含的格子的最小数目。 如果无法分割,则输出 0。 输入格式 4
共分享92篇相关文档