`
czxzz
  • 浏览: 34293 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
文章分类
社区版块
存档分类

2009年度腾讯TIC创新大赛 试题

阅读更多
Problem A: University
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 1402   Accepted: 545

Description

企鹅大学有很多很多名学生,课程也很多。譬如企鹅语,北极熊语,企鹅初级数学,企鹅高级数学等等等等…… 现在,企鹅大学的校长想请你为他们写一个程序:计算总分的程序。请你由他们输入课程的数量以及一个学生每门课程的分数,输出该学生的总分。

Input

第一行:一个整数n(1 ≤ n ≤ 5000),代表企鹅大学的课程数目。
第2至第n+1行:每行有一个1整数,第i+1行代表某一位学生在第i门课上取得的分数。分数为0到100的整数。

Output

一个整数。代表该学生在n门课中所得的总分。

Sample Input

3
100
99
100

Sample Output

299
Problem B: Doudou

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 1724   Accepted: 198
Description

有只企鹅叫豆豆,总是被别的企鹅欺负。豆豆在长期的隐忍之后,掌握了所有企鹅的高度和攻击力强度,还得到了一把黄金剑。在拥有了黄金剑以后,豆豆终于可以展开绝地大反击。但这把黄金剑的用法却很奇怪。

首先,豆豆第一次可以选择任何一只企鹅开始挑战。豆豆这一次必胜。

再次,当豆豆已经挑战过某一只企鹅后,再下一次的挑战对象只能是比上一名对手高,且比上一名对手攻击力强的企鹅。这样豆豆必胜。否则黄金剑会觉得打的没意思而故意发脾气输掉。豆豆还会被大家集体暴打。

面对着这把脾气很大的黄金剑,豆豆想请你帮助他计算一下,他最多可以连续击败多少只企鹅?

Input
第一行:一个数据n,代表企鹅群里除了豆豆一共有n(1 ≤ n ≤ 1000)只企鹅。 第2至第n+1行:每行2个数字。第i+1行的第一个数字为企鹅i的高度。第i+1行的第二个数字为企鹅i的攻击力。0 ≤ 高度,攻击力 ≤ 1,000,000。
Output
一个数。代表豆豆最多可以连续击败的企鹅数。
Sample Input

Sample Input #1 Sample Input #2
3 1 3 3 2 2 4 5 10 1 9 2 7 3 6 4 5 5

Sample Output


Sample Output #1 Sample Output #2
2 1

 

import java.io.*;
import java.util.*;

public class Main
{	
	static int[] shengao;	
	static int[] liqi;	
	static int[] check = new int[1000];
	
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		shengao = new int[n];
		liqi = new int[n];
		
		for (int i = 0; i < n; i++)
		{
			shengao[i] = cin.nextInt();
			liqi[i] = cin.nextInt();
		}
		
		int max = 1;
		for (int i = 0; i < n; i++)
		{
			if (check(i, n) > max)
				max = check(i, n);
		}
		System.out.println(max);
		
	}	
	static int check(int i, int n)
	{
		if (check[i] == 0)
		{
			int[] array = new int[10000];
			
			int geshu = 0;
			
			for (int j = 0, temp = 0; j < n; j++)
			{
				if (liqi[j] > liqi[i] && shengao[j] > shengao[i])
				{
					array[temp] = j;
					temp++;
					geshu++;
				}
			}
			int max = 0;
			for (int j = 0; j < geshu; j++)
			{
				int temp = check(array[j], n);
				if (temp > max)
					max = temp;
			}
			if (geshu == 0)
			{
				check[i] = 1;
				return 1;
			}
			else
			{
				check[i] = max + 1;
				return max + 1;
			}			
		}
		else
			return check[i];
	}
}

  

 


Problem C: Ball
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 264   Accepted: 85

Description

给出空间上两个运动的小球,球心坐标在分别是A(xa , ya , 0),B(xb , yb , 0),半径分别为Ra , Rb,速度分别为Va( vax, vay , 0), Vb( vbx , vby, 0)。判断两个小球是否会碰撞,若会碰撞, 输出首次碰撞时的时刻和两个小球的坐标;若不会碰撞,输出“Impossible”(球心和速度的z坐标恒为0,可将本题视为只是平面上的运动。初始时刻为0,若初始时刻小球贴在一起,视为首次碰撞)。

Input

第一行:一个整数T,(T ≤ 30),表示下面有T组数据。 接下来,每两行组成一组数据,首行包含5个实数,用空格隔开,依次是xa , ya , vax, vay , Ra,下面一行也包含5个实数,依次是xa , ya , vbx , vby, Rb。每组数据之间有一个空行。

Output

对于每组数据,如果两个小球会碰撞,输出首次碰撞时的时刻t,和两个小球的坐标xap , yap , xbp , ybp ,用空格隔开,保留三位小数。如果不能,输出“Impossible”。

Sample Input

3
100 200 0 0 55
100 100 0 0 45

131 123 45 2 43
454 230 0 -5 35

100 100 1 1 31
200 200 2 2 23

Sample Output

0.000 100.000 200.000 100.000 100.000
6.179 409.053 135.358 454.000 199.105
Impossible
Problem D: String
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 239   Accepted: 3

Description

给定一个字符串S[1..n]和一个整数T,现在需要在字符串S中找出长度不小于T的一个子串,使得其在原串中不重叠出现的次数最多,求这个次数。

Input

第一行:一个整数T(T > 1) 第二行:一个字符串S,且仅包含小写字母,字符串长度不超过10000

Output

一个整数。代表出现最多的次数 如果没有满足条件的解则输出0

Sample Input

2
ababab

Sample Output 3

import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		String str = cin.next();
		int max = 1;
		if (n > str.length())
			System.out.println("0");
		else
		{
			for (; n < str.length(); n++)
			{
				for (int i = 0; i < str.length() - n; i++)
				{
					String tempstr = str.substring(i, i + n);
					int temp = check(tempstr, str);
					// System.out.println(tempstr+" "+temp);
					if (temp > max)
					{
						max = temp;
					}
				}
			}
			System.out.println(max);
		}
	}
	
	static int check(String sub, String str)
	{
		int count = 0;
		int idx = 0;
		while ((idx = str.indexOf(sub, idx)) != -1)
		{
			count++;
			idx += sub.length();
		}
		return count;
	}
}
 


Problem E: Papercut
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 46   Accepted: 15

Description

现在桌面上有一张矩形纸,上边有n×m个格子,每个格子有一个数字。 每张矩形纸可以算出一个数值F,F是由纸张里任意两个不同的格子里的数字相乘之和。如果该纸只有一个格子,那么F=0。

剪纸规则是: 1、沿格子边缘一直剪成两个矩形纸,每张纸里必须有数字。 2、每次剪纸在桌面上任意选一张矩形纸,进行1操作,再把剪出来的两张纸放到桌面。

现在你可以对桌面上的纸最多剪k次,问最后桌面上所有矩形纸的F值之和最小是多少?

1 ≤ n ≤ 10 1 ≤ m ≤ 10 1 ≤ k ≤ 50

Input

第一行:3个整数n, m, k 接下来n行:每行m个正整数,范围在[1,10],第i行第j个数表示当前桌面那张矩形纸里边第i行第j个格子里的数字。

Output

一个整数。代表最小F值和。

Sample Input


Sample Input #1 Sample Input #2
4 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   10 10 5 4 2 3 5 6 10 1 6 5 8 3 6 9 1 7 10 7 10 8 1 7 8 3 3 2 5 9 9 8 2 5 5 9 9 3 10 2 9 10 2 1 1 6 7 6 8 3 9 6 8 7 1 2 5 3 2 3 7 8 10 10 9 8 9 7 8 10 7 3 9 6 3 6 2 1 7 10 6 7 2 2 4 8 4 5 9 10 5 9 10 7 4 3 2 4 9 9 9 8 1

Sample Output


Sample Output #1 Sample Output #2
18 26612

Hint

Sample 1说明: 按照下面方式剪纸4次
1   1   1   1
-------------
1 | 1 | 1 | 1
   |    |    |
1 | 1 | 1 | 1
   |    |    |
1 | 1 | 1 | 1
得到6+3+3+3+3=18

 

http://xiezezhun.blogbus.com/logs/39237188.html

1
0
分享到:
评论
1 楼 wenxiang_tune 2009-05-16  
  

相关推荐

Global site tag (gtag.js) - Google Analytics