2013-8-14大一大二暑期组队训练赛

1001

Time Limit : 5000/2000ms (Java/Other)   Memory Limit : 65535/65535K (Java/Other)
Total Submission(s) : 11   Accepted Submission(s) : 2

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

You are to write a module that will check the correctness of given words using a known dictionary 
of all correct words  in all their forms, for a new spell checking program,. 
If the word is absent in the dictionary then it can be replaced by correct words (from the dictionary) 
that can be  obtained by one of the following operations: 
deleting of one letter from the word; 
replacing of one letter in the word with an arbitrary letter; 
inserting of one arbitrary letter into the word. Your task is to write the program that will find all
possible replacements from the dictionary for  every given word. 

Input

The first part of the input file contains all words from the dictionary. Each word occupies its own line. 
This part is finished by the single character '#' on a separate line.
All words are different. There will be at most 10000 words in the dictionary. 
The next part of the file contains all words that are to be checked. Each word occupies its own line. 
This part is also finished by the single character '#' on a separate line. There will be at most 50 
words that are to be checked. All words in the input file (words from the dictionary and words to be checked) 
consist only of small alphabetic characters and each one contains 15 characters at most. 

Output

Write to the output file exactly one line for every checked word in the order of their appearance 
in the second part of the  input file. If the word is correct (i.e. it exists in the dictionary) 
write the message: " is correct". If the word is not correct  then write this word first, 
then write the character ':' (colon), and after a single space write all its possible replacements, 
separated by spaces. The replacements should be written in the order of their appearance in the dictionary
(in the first part of the input file). If there are no replacements for this word then the line feed 
should immediately  follow the colon(no space).

Sample Input

i
is
has
have
be
my
more
contest
me
too
if
award
#
me
aware
m
contest
hav
oo
or
i
fi
mre
#

Sample Output

me is correct
aware: award
m: i my me
contest is correct
hav: has have
oo: too
or: 
i is correct
fi: i
mre: more me


代码暂无

1002

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 23   Accepted Submission(s) : 5

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子。要求摆放时任意的两个棋子不能放
在棋盘中的同一行或者同一列, 请编程求解对于给定形状和大小的棋盘,
摆放k个棋子的所有可行的摆放方案C。

Input

输入含有多组测试数据。 
每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,
以及摆放棋子的数目。 n <= 8 , k <= n 
当为-1 -1时表示输入结束。 
随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表示空白区域
(数据保证不出现多余的空白行或者空白列)。 

Output

对于每一组数据,给出一行输出,输出摆放的方案数目C (数据保证C<2^31)

Sample Input

2 1
#.
.#
4 4
...#
..#.
.#..
#...
-1 -1

Sample Output

2
1

//01479140	2013-08-14 16:22:53	Accepted	1002	62 MS	1600 KB	Java	hahacomeonimport java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {private static char map[][];private static boolean vis[];static int n,sum=0,k;public static void main(String[] args) {BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));try {while(true){sum=0;String s[]=bf.readLine().split(" ");n=Integer.parseInt(s[0]);k=Integer.parseInt(s[1]);if(n==-1&&k==-1)break;map=new char[n][n];vis=new boolean[n];for(int i=0;i<n;i++){String str=bf.readLine();for(int j=0;j<str.length();j++)map[i][j]=str.charAt(j);}dfs(0,k);System.out.println(sum);}} catch (Exception e) {e.printStackTrace();}}private static void dfs(int num,int k1) {if(k1==0){sum++;return;}if(num==n)return;for(int i=0;i<n;i++){if(map[num][i]=='#'&&!vis[i]){vis[i]=true;dfs(num+1,k1-1);vis[i]=false;}}dfs(num+1,k1);}
}

1003

Time Limit : 5000/2000ms (Java/Other)   Memory Limit : 65535/65535K (Java/Other)
Total Submission(s) : 18   Accepted Submission(s) : 3

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

A company uses trucks of different types. The company has its own code describing each type of a truck. 
The code is simply a string of exactly seven lowercase letters (each letter on each position has a very special 
meaning but that is unimportant for this task). At the beginning of company's history, just a single truck type
was used but later other types were derived from it, then from the new types another types were derived,
and so on. 

One thing historians tried to find out is so called derivation plan -- i.e. how the truck types were derived. They 
defined the distance of truck types as the number of positions with different letters in truck type codes. 
They also assumed that each truck type was derived from exactly one other truck type (except for the first truck 
type which was not derived from any other type). The quality of a derivation plan was then defined as 
1/Σ(to,td)d(to,td)

where the sum goes over all pairs of types in the derivation plan such that to is the original type and td the type 
derived from it and d(to,td) is the distance of the types. 
Since historians failed, you are to write a program to help them. Given the codes of truck types, your program 
should find the highest possible quality of a derivation plan. 

Input

The input consists of several test cases. Each test case begins with a line containing the number of truck types,
N, 2 <= N <= 2 000. Each of the following N lines of input contains one truck type code 
(a string of seven lowercase letters).
You may assume that the codes uniquely describe the trucks, i.e., no two of these N lines are the same.
The input is terminated with zero at the place of number of truck types.

Output

For each test case, your program should output the text "The highest possible quality is 1/Q.", 
where 1/Q is the quality of the best derivation plan.

Sample Input

4
aaaaaaa
baaaaaa
abaaaaa
aabaaaa
0

Sample Output

The highest possible quality is 1/3.

#include <stdio.h>
#define M 2005
#define A 100000000
int n,sum;
int map[M][M],dis[M];
char s[M][8];
int min(int a,int b)
{return a<b?a:b;
}
void prim()
{int i,j,pos,p,min1;for(i=1;i<=n;i++)dis[i]=A;pos=1;sum=0;for(i=1;i<n;i++){dis[pos]=-1;min1=A;for(j=1;j<=n;j++){if(j!=pos&&dis[j]>=0){dis[j]=min(dis[j],map[pos][j]);if(dis[j]<min1){min1=dis[j];p=j;}}}pos=p;sum+=min1;}
}
int main()
{int i,j,k,t;while(scanf("%d",&n),n){for(i=1;i<=n;i++){scanf("%s",&s[i]);for(j=i-1;j>=1;j--){for(k=0,t=0;k<7;k++)if(s[i][k]!=s[j][k])	t++;map[i][j]=map[j][i]=t;}}prim();printf("The highest possible quality is 1/%d.\n",sum);}return 0;
}

1004

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 65   Accepted Submission(s) : 20

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

John has N cows (1 ≤ N ≤ 80,000) 
Each cow i has a specified height hi (1 ≤ hi ≤ 1,000,000,000) and is standing in a line of cows all facing 
east (to the right in our diagrams). Therefore, cow i can see the tops of the heads of cows 
in front of her (namely cows i+1, i+2, and so on), for as long as these cows are strictly 
shorter than cow i.
Consider this example:
Num:  1 2 3 4 5 6
Height: 10 3 7 4 12 2
Cows facing right -->

Cow#1 can see the hairstyle of cows #2, 3, 4
Cow#2 can see no cow's hairstyle
Cow#3 can see the hairstyle of cow #4
Cow#4 can see no cow's hairstyle
Cow#5 can see the hairstyle of cow 6
Cow#6 can see no cows at all!
Let ci denote the number of cows whose hairstyle is visible from cow i; please compute the 
sum of c1 through cN. For this example, the desired is answer 3 + 0 + 1 + 0 + 1 + 0 = 5.

Input

Line 1: The number of cows, N. 
Lines 2..N+1: Line i+1 contains a single integer that is the height of cow i.

Output

Line 1: A single integer that is the sum of c1 through cN.

Sample Input

6
10
3
7
4
12
2

Sample Output

5


import java.util.Scanner;
public class Main {//01479166	2013-08-14 16:32:23	Accepted	1004	265 MS	3688 KB	Java	hahacomeonpublic static void main(String[] args) {Scanner input=new Scanner(System.in);while(input.hasNext()){int n=input.nextInt();int a[]=new int[n];for(int i=0;i<n;i++){a[i]=input.nextInt();}int sum=0;for(int i=0;i<n-1;i++){for(int j=i+1;j<n&&a[j]<a[i];j++)sum++;}System.out.println(sum);}}
}

1005

Time Limit : 5000/3000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 23   Accepted Submission(s) : 6

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

将字母A-Z编码,A为1,B为2,……依此类推,Z为26,则ABC编码为123。但是反向解码时,解码结果却不唯一,
比如123可以解码为 1-2-3:ABC,解码为12-3:LC,解码为1-23:AW
(注意,127不能解码为1-27,因为范围只能为1-26)。

Input

现给出一组编码后的数字串,让你求该数字串可以有几种解码方式(上例中,123对应着3种解码方式)。
问题输入将保证其为一个合法的数字串。比如100不是一个合法的数字串,
因为0或者00不代表一个字母;此外01不能视为1。

Output

解码方式总数。

Sample Input

25114
1111111111
3333333333

Sample Output

6
89
1

//01479251	2013-08-14 16:58:43	Accepted	1005	156 MS	2928 KB	Java	hahacomeon
import java.util.Scanner;
public class Main {private static int a[],sum=0,n;public static void main(String[] args) {Scanner input=new Scanner(System.in);while(input.hasNext()){sum=0;String s=input.nextLine();n=s.length();a=new int[n];//int a[]=new int[n];for(int i=0;i<s.length();i++){a[i]=(int)(s.charAt(i)-'0');}dfs(0);System.out.println(sum);}}private static void dfs(int i) {if(i==n){sum++;return;}if(a[i]==0)return;dfs(i+1);if(i+2<=n&&a[i]*10+a[i+1]<=26){dfs(i+2);}}
}

1006

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 45   Accepted Submission(s) : 23

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数
(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,
除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。

你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。

Input

输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字的长度不大于1000。 

输入数据保证:分割得到的非负整数不会大于100000000;输入数据不可能全由‘5’组成

Output

对于每个测试用例,输出分割得到的整数排序的结果,相邻的两个整数之间用一个空格分开,每组输出占一行。

Sample Input

0051231232050775

Sample Output

0 77 12312320

import java.util.Arrays;
import java.util.Scanner;
public class Main {public static void main(String[] args) {Scanner input=new Scanner(System.in);while(input.hasNext()){String s=input.nextLine();String s1[]=s.split("5");int a[]=new int[s1.length];int e=0;for(int i=0;i<s1.length;i++){if(s1[i].length()>0){a[e++]=Integer.parseInt(s1[i]);}}Arrays.sort(a,0,e);for(int i=0;i<e-1;i++){System.out.print(a[i]+" ");}System.out.println(a[e-1]);}}
}

1007

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 16   Accepted Submission(s) : 5

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

编写程序,产生由2,3,5这3个数字符号所构成、长度为n的字符串,
并且在字符串中对于任何一个子串而言,都不会有相邻的、
完全相同的子串;

Input

字符串长度n(1<=n<=15);

Output

无相邻重复子串的所有字符串,每个字符串换行输出。

Sample Input

4

Sample Output

2325
2352
2353
2523
2532
2535
3235
3252
3253
3523
3525
3532
5232
5235
5253
5323
5325
5352

/** 01479332	2013-08-14 17:43:41	Accepted	1007	187 MS	3908 KB	Java	hahacomeon*/
import java.util.Scanner;
public class Main {private static int n;static String a[]={"2","3","5"};public static void main(String[] args) {Scanner input=new Scanner(System.in);while(input.hasNext()){n=input.nextInt();String s="";dfs(n,s);}}private static void dfs(int n1, String s) {if(n-n1>1&&s.charAt(s.length()-1)==s.charAt(s.length()-2))return;if(n-n1>3)for(int i=s.length()-2;i>=s.length()/2;i--){boolean ok=false;for(int j=0;i-j>=s.length()/2;j++){String s2=s.substring(i-j);if((i-j)<s2.length()){ok=true;break;}String s3=s.substring((i-j)-s2.length(), i-j);if(s2.equals(s3))return;}if(ok)break;}if(n1==0){System.out.println(s);return;}for(int i=0;i<3;i++){dfs(n1-1,s+a[i]);}}
}



 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/265709.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

dataframe常用操作_Pandas | Dataframe的merge操作,像数据库一样尽情join

点击上方蓝字&#xff0c;关注并星标&#xff0c;和我一起学技术。今天是pandas数据处理第8篇文章&#xff0c;我们一起来聊聊dataframe的合并。常见的数据合并操作主要有两种&#xff0c;第一种是我们新生成了新的特征&#xff0c;想要把它和旧的特征合并在一起。第二种是我们…

2.空间配置器

SGI 特殊的空间配置器 std::alloc 一般而言&#xff0c;我们习惯的C内存配置操作和释放操作是这样的 class Foo{…..} Foo* pf new Foo; delete pf; new包含两阶段操作 &#xff08;1&#xff09;调用 ::operator new 配置内存 &#xff08;2&#xff09;调用 Foo::Foo() …

Github的简单使用(网页版)

目录Git和GithubGithub基础概念注册Github账号创建仓库及文件新建仓库新建文件文件的编辑和删除编辑或修改文件删除文件文件的上传文件的查找及下载文件的查找文件的下载IssuesFork开源项目贡献流程Git和Github 什么是Git Git是一个免费、开源的版本控制软件 什么是版本控制…

常用到的正则表达式

2019独角兽企业重金招聘Python工程师标准>>> 常用的正则表达式 1、匹配只含有英文字母和阿拉伯数字 ^[a-zA-Z0-9-]$ 2、匹配电子邮件地址 ^[_a-z0-9-](\.[_a-z0-9-])*[a-z0-9-](\.[a-z0-9-])*$ 3、匹配中文字符 [\u4e00-\u9fa5] 4、匹配国内座机电话号码 (\d{3}-|\d…

docker多个容器一起打包_docker如何将容器打包成镜像

可以使用docker commit命令来完成&#xff0c;docker commit可以从容器创建一个新的镜像。语法格式&#xff1a;docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]参数说明&#xff1b;-a :提交的镜像作者&#xff1b;-c :使用Dockerfile指令来创建镜像&#xff1b;-m :提…

CSDN绑定GitHub账号

目录1.点击自己头像进入个人中心2.点击账号设置&#xff0c;选择绑定三方账号3.选择GitHub绑定绑定成功&#xff0c;主页获取勋章1.点击自己头像进入个人中心 2.点击账号设置&#xff0c;选择绑定三方账号 3.选择GitHub绑定 绑定成功&#xff0c;主页获取勋章

My97DatePicker在asp.net项目中的使用

1、去官网下载 My97DatePicker 包 http://www.my97.net/ 2、比如实现如下图所示功能 2.1 先把下载来的包添加到解决方案 2.2 然后在页面引用css文件和js文件 <link href"My97DatePicker/skin/WdatePicker.css" rel"stylesheet" type"text/css"…

机械秒表的使用方法_让console.log()不再是你的唯一选项js日志输出6种方法

几乎所有的javascript开发者最常使用的日志打印调试api都是console.log(),其实还有很多的选项供我们选择&#xff0c;笔者下面就为大家一一介绍.一、console.table()console.table()是我非常建议大家去使用的方法&#xff0c;它可以接受JSON或数组并以表格格式打印&#xff0c;…

Git的安装(附安装包)

更多干货推荐可以去牛客网看看&#xff0c;他们现在的IT题库内容很丰富&#xff0c;属于国内做的很好的了&#xff0c;而且是课程刷题面经求职讨论区分享&#xff0c;一站式求职学习网站&#xff0c;最最最重要的里面的资源全部免费&#xff01;&#xff01;&#xff01;点击进…

【10.20校内测试】【小模拟】【无向图建树判奇偶环】【树上差分】

Solution 和后面两道题难度差距太大了吧&#xff01;&#xff01; 显然就只是个小模拟&#xff0c;注意判0就行了。 Code #include<bits/stdc.h> using namespace std;char s[100005];int main() {freopen("expression.in", "r", stdin);freopen(&qu…

基础知识整理

1. 数据结构与算法 1.1 书籍 &#xff08;1&#xff09;算法导论 &#xff08;2&#xff09;编程之美 &#xff08;3&#xff09;编程珠玑 &#xff08;4&#xff09;数据结构&#xff08;C语言版&#xff09; &#xff08;5&#xff09;CareerCup.Cracking.the.Technical.Inte…

验票证明怎么打印_OFD电子发票如何查验、打开、打印?如何电子归档?

原标题&#xff1a;OFD电子发票如何查验、打开、打印&#xff1f;如何电子归档&#xff1f;电子发票是现代信息社会的产物&#xff0c;具有与纸质发票相同的凭证属性。它的诞生有利于进一步简化发票的流转、存储、查验&#xff0c;可以大幅降低纳税人领用、运输、存储和管理成本…

微信(QQ)截图时,无法保留鼠标右键菜单选项内容

问题描述 按下右键后弹出菜单&#xff0c;再按下QQ截图热键"Ctrl&#xff0b;Alt&#xff0b;A"&#xff08;微信"Ctrl&#xff0b;A"&#xff09;时&#xff0c;却发现菜单不见了。 微信的解决方法 先按下"Alt"键不放&#xff0c;再按住&quo…

js闭包的使用

js闭包的使用 学习了&#xff1a;https://www.cnblogs.com/ZinCode/p/5551907.html 终于用上了闭包&#xff0c;还是有些生涩&#xff1b;好像柿子还没熟&#xff1b; function createList(list, divObject) {for (var i 0; i < list.length; i) {var monitor list[i];var…

使用WebClient请求WCF REST服务

2019独角兽企业重金招聘Python工程师标准>>> 接上篇”WCF实现REST服务“&#xff0c;服务端有了&#xff0c;我们看看客户端怎么访问&#xff0c;由于JS跨域的限制&#xff0c;这里通过WebClient做在后台代理来访问&#xff0c;话不多说&#xff0c;直接上代码。 1…

python谁是卧底游戏流程图_虎牙小程序—谁是卧底 |明星互动游戏

主播连麦&#xff0c;观众互动每次都是唱歌跳舞聊天&#xff0c;你是否有为直播内容无吸引力而担心&#xff1f;别担心&#xff01;最经典的明星互动游戏“谁是卧底”终于来了&#xff0c;主播直播连麦就可以玩&#xff01;最重要的是&#xff01;&#xff01;&#xff01;观众…

Git的工作流程简介

目录Git的工作区域Git的基本流程1.将工作区的代码添加到暂存区2.将暂存区的文件提交到本地仓库3.将暂存区的文件提交到远程仓库Git的工作区域 Git的基本流程 图形化方式操作 命令行模式&#xff08;Linux系统常用&#xff09;操作 1.将工作区的代码添加到暂存区 查看文件状态使…

git常用配置(指令)

1、配置用户名和邮箱 (1) 指令设置 $ git config --global user.name "username" $ git config --global user.email johndoeexample.com (2) 修改配置文件.gitconfig 2、配置ssh key免密登录 (1) 生成密钥 $ ssh-keygen -t rsa -C 1046407517qq.com (2) 在github添加…

PG git pull

2019独角兽企业重金招聘Python工程师标准>>> remote: Counting objects: 347, done. remote: Compressing objects: 100% (159/159), done. remote: Total 159 (delta 136), reused 0 (delta 0) Receiving objects: 100% (159/159), 23.16 KiB, done. Resolving del…

c51单片机led奇数偶数亮_两STM32单片机串口通讯实验

一、实验思路连接两个STM32单片机的串口引脚&#xff0c;单片机A进行发送&#xff0c;单片机B进行接收。单片机B根据接收到单片机A的指令来点亮或熄灭板载LED灯&#xff0c;通过实验现象来验证是否通讯成功。二、实验器材两套STM32F103C8T6单片机开发板、ST-Link下载器、杜邦线…