Problem A: Doudou
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 Description有只企鹅叫豆豆,总是被别的企鹅欺负。豆豆在长期的隐忍之后,掌握了所有企鹅的高度和攻击力强度,还得到了一把黄金剑。在拥有了黄金剑以后,豆豆终于可以展开绝地大反击。但这把黄金剑的用法却很奇怪。首先,豆豆第一次可以选择任何一只企鹅开始挑战。豆豆这一次必胜。再次,当豆豆已经挑战过某一只企鹅后,再下一次的挑战对象只能是比上一名对手高,且比上一名对手攻击力强的企鹅。这样豆豆必胜。否则黄金剑会觉得打的没意思而故意发脾气输掉。豆豆还会被大家集体暴打。面对着这把脾气很大的黄金剑,豆豆想请你帮助他计算一下,他最多可以连续击败多少只企鹅?Input第一行:一个数据n,代表企鹅群里除了豆豆一共有n(1 ≤ n ≤ 1000)只企鹅。
第2至第n+1行:每行2个数字。第i+1行的第一个数字为企鹅i的高度。第i+1行的第二个数字为企鹅i的攻击力。0 ≤ 高度,攻击力 ≤ 1,000,000。Output一个数。代表豆豆最多可以连续击败的企鹅数。
Sample InputSample Input #1 Sample Input #2 31 33 22 4 510 19 27 36 45 5 Sample Output299HintSample Output #1 Sample Output #2
2 1 [Submit]
Problem B: Ball
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 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 Input3
100 200 0 0 55
100 100 0 0 45131 123 45 2 43
454 230 0 -5 35100 100 1 1 31
200 200 2 2 23
Sample Output0.000 100.000 200.000 100.000 100.000
6.179 409.053 135.358 454.000 199.105
Impossible
[Submit] Problem C: University
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 10 Accepted: 10 Description企鹅大学有很多很多名学生,课程也很多。譬如企鹅语,北极熊语,企鹅初级数学,企鹅高级数学等等等等…… 现在,企鹅大学的校长想请你为他们写一个程序:计算总分的程序。请你由他们输入课程的数量以及一个学生每门课程的分数,输出该学生的总分。 Input第一行:一个整数n(1 ≤ n ≤ 5000),代表企鹅大学的课程数目。
第2至第n+1行:每行有一个1整数,第i+1行代表某一位学生在第i门课上取得的分数。分数为0到100的整数。Output一个整数。代表该学生在n门课中所得的总分。Sample Input3
100
99
100
Sample Output299[Submit]
Problem D: String
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 Description给定一个字符串S[1..n]和一个整数T,现在需要在字符串S中找出长度不小于T的一个子串,使得其在原串中不重叠出现的次数最多,求这个次数。
Input第一行:一个整数T(T > 1)
第二行:一个字符串S,且仅包含小写字母,字符串长度不超过10000Output一个整数。代表出现最多的次数
Sample Input2
ababab
Sample Output3[Submit]
Problem E: Papercut
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 Description现在桌面上有一张矩形纸,上边有n×m个格子,每个格子有一个数字。 每张矩形纸可以算出一个数值F,F是由纸张里任意两个不同的格子里的数字相乘之和。如果该纸只有一个格子,那么F=0。 剪纸规则是:
1、沿格子边缘一直剪成两个矩形纸,每张纸里必须有数字。
2、每次剪纸在桌面上任意选一张矩形纸,进行1操作,再把剪出来的两张纸放到桌面。
现在你可以对桌面上的纸最多剪k次,问最后桌面上所有矩形纸的F值之和最小是多少? 1 ≤ n ≤ 10
1 ≤ m ≤ 10
1 ≤ k ≤ 50Input第一行:3个整数n, m, k
接下来n行:每行m个正整数,范围在[1,10],第i行第j个数表示当前桌面那张矩形纸里边第i行第j个格子里的数字。Output一个整数。代表最小F值和。
Sample InputSample Input #1 Sample Input #2 4 4 41 1 1 11 1 1 11 1 1 11 1 1 1 10 10 54 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 OutputSample Output #1 Sample Output #2 18 26612 [Submit]
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 Description有只企鹅叫豆豆,总是被别的企鹅欺负。豆豆在长期的隐忍之后,掌握了所有企鹅的高度和攻击力强度,还得到了一把黄金剑。在拥有了黄金剑以后,豆豆终于可以展开绝地大反击。但这把黄金剑的用法却很奇怪。首先,豆豆第一次可以选择任何一只企鹅开始挑战。豆豆这一次必胜。再次,当豆豆已经挑战过某一只企鹅后,再下一次的挑战对象只能是比上一名对手高,且比上一名对手攻击力强的企鹅。这样豆豆必胜。否则黄金剑会觉得打的没意思而故意发脾气输掉。豆豆还会被大家集体暴打。面对着这把脾气很大的黄金剑,豆豆想请你帮助他计算一下,他最多可以连续击败多少只企鹅?Input第一行:一个数据n,代表企鹅群里除了豆豆一共有n(1 ≤ n ≤ 1000)只企鹅。
第2至第n+1行:每行2个数字。第i+1行的第一个数字为企鹅i的高度。第i+1行的第二个数字为企鹅i的攻击力。0 ≤ 高度,攻击力 ≤ 1,000,000。Output一个数。代表豆豆最多可以连续击败的企鹅数。
Sample InputSample Input #1 Sample Input #2 31 33 22 4 510 19 27 36 45 5 Sample Output299HintSample Output #1 Sample Output #2
2 1 [Submit]
Problem B: Ball
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 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 Input3
100 200 0 0 55
100 100 0 0 45131 123 45 2 43
454 230 0 -5 35100 100 1 1 31
200 200 2 2 23
Sample Output0.000 100.000 200.000 100.000 100.000
6.179 409.053 135.358 454.000 199.105
Impossible
[Submit] Problem C: University
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 10 Accepted: 10 Description企鹅大学有很多很多名学生,课程也很多。譬如企鹅语,北极熊语,企鹅初级数学,企鹅高级数学等等等等…… 现在,企鹅大学的校长想请你为他们写一个程序:计算总分的程序。请你由他们输入课程的数量以及一个学生每门课程的分数,输出该学生的总分。 Input第一行:一个整数n(1 ≤ n ≤ 5000),代表企鹅大学的课程数目。
第2至第n+1行:每行有一个1整数,第i+1行代表某一位学生在第i门课上取得的分数。分数为0到100的整数。Output一个整数。代表该学生在n门课中所得的总分。Sample Input3
100
99
100
Sample Output299[Submit]
Problem D: String
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 Description给定一个字符串S[1..n]和一个整数T,现在需要在字符串S中找出长度不小于T的一个子串,使得其在原串中不重叠出现的次数最多,求这个次数。
Input第一行:一个整数T(T > 1)
第二行:一个字符串S,且仅包含小写字母,字符串长度不超过10000Output一个整数。代表出现最多的次数
Sample Input2
ababab
Sample Output3[Submit]
Problem E: Papercut
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 0 Accepted: 0 Description现在桌面上有一张矩形纸,上边有n×m个格子,每个格子有一个数字。 每张矩形纸可以算出一个数值F,F是由纸张里任意两个不同的格子里的数字相乘之和。如果该纸只有一个格子,那么F=0。 剪纸规则是:
1、沿格子边缘一直剪成两个矩形纸,每张纸里必须有数字。
2、每次剪纸在桌面上任意选一张矩形纸,进行1操作,再把剪出来的两张纸放到桌面。
现在你可以对桌面上的纸最多剪k次,问最后桌面上所有矩形纸的F值之和最小是多少? 1 ≤ n ≤ 10
1 ≤ m ≤ 10
1 ≤ k ≤ 50Input第一行:3个整数n, m, k
接下来n行:每行m个正整数,范围在[1,10],第i行第j个数表示当前桌面那张矩形纸里边第i行第j个格子里的数字。Output一个整数。代表最小F值和。
Sample InputSample Input #1 Sample Input #2 4 4 41 1 1 11 1 1 11 1 1 11 1 1 1 10 10 54 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 OutputSample Output #1 Sample Output #2 18 26612 [Submit]
class University {
public static void main(String[] args) {
int sum=0;
int a[]=null;
Scanner cin=new Scanner(System.in);
int n =cin.nextInt();
if(1<=n && n<=5000){
a=new int[n];
for(int i=0;i<a.length;i++){
a[i]=cin.nextInt();
}
}else {
System.exit(0);
}
for(int i=0;i<n;i++){
sum+=a[i];
}
System.out.println(sum);
}}
#include <algorithm>
using namespace std;
struct qier
{
int height;
int strength;
};qier a[1050]; bool cmp(const qier b, const qier c)
{
if (b.height!=c.height)
{
return b.height < c.height;
}
else
return b.strength < c.strength;
}int main()
{
// freopen("in.txt","r",stdin);
int n = 0,sum = 1,sum_temp = 1;
int pre = 0, next = 0;
int i,j;
cin >> n;
for (i = 0; i < n; ++i)
{
cin >> a[i].height >> a[i].strength;
}
if (n == 1)
{
if (a[0].height > 0)
{
cout << 1;
}
else
cout << 0;
return 0;
}
sort(a,a+n,cmp);
for (i = 0; i < n; ++i)
{
cout << a[i].height << " " << a[i].strength << endl;
}
for (i = 0; i < n; ++i)
{
pre = i;
next = pre+1;
sum_temp = 1;
while(pre < n && next < n)
{
if ( (a[next].height > a[pre].height) && (a[next].strength > a[pre].strength) )
{
++sum_temp;
pre = next;
++next;
}
else
{
++next;
}
}
if (sum_temp > sum)
{
sum = sum_temp;
}
}
cout << sum;
return 0;
}
#include <algorithm>
using namespace std;
struct qier
{
int height;
int strength;
};qier a[1050]; bool cmp(const qier b, const qier c)
{
if (b.height!=c.height)
{
return b.height < c.height;
}
else
return b.strength < c.strength;
}int main()
{
// freopen("in.txt","r",stdin);
int n = 0,sum = 1,sum_temp = 1;
int pre = 0, next = 0;
int i,j;
cin >> n;
for (i = 0; i < n; ++i)
{
cin >> a[i].height >> a[i].strength;
}
if (n == 1)
{
if (a[0].height > 0)
{
cout << 1;
}
else
cout << 0;
return 0;
}
sort(a,a+n,cmp);
for (i = 0; i < n; ++i)
{
cout << a[i].height << " " << a[i].strength << endl;
}
for (i = 0; i < n; ++i)
{
pre = i;
next = pre+1;
sum_temp = 1;
while(pre < n && next < n)
{
if ( (a[next].height > a[pre].height) && (a[next].strength > a[pre].strength) )
{
++sum_temp;
pre = next;
++next;
}
else
{
++next;
}
}
if (sum_temp > sum)
{
sum = sum_temp;
}
}
cout << sum;
return 0;
}
* 2009-05-09
*/
#include<iostream>
#include<vector>
using namespace std;class M{
public:
int hight;
int force;
M& operator=(const M& m){
this->hight = m.hight;
this->force = m.force;
return *this;
}
};void function1(vector<M>& v,int n){
M tempt;
for(int i = 0;i<n;i++){
for(int j = i;j<n;j++){
if(v[i].hight>v[j].hight){
tempt = v[j];
v[j] = v[i];
v[i] = tempt;
}
}
}
}void function2(vector<M>& v,int n){
M tempt;
for(int i = 0;i<n;i++){
for(int j = i;j<n;j++){
if(v[i].force>v[j].force){
tempt = v[j];
v[j] = v[i];
v[i] = tempt;
}
}
}
}int main(){
vector<M> v;
vector<M> v2;
M var;
int n;
cin>>n;
int h;
int f;
for(int i = 0;i<n;i++){
cin>>h>>f;
var.hight = h;
var.force = f;
v.push_back(var);
v2.push_back(var);
}
int counter1 = 1;
int counter11 = 1;
int counter2 = 1;
int counter22 = 1;
// 处理
function1(v,n);
for(int x = 0;x<v.size();x++){
for(int i = x;i<v.size();i++){
if(i+1<n&&v[i+1].force>v[i].force){
counter11++;
}
else{
if(counter11>counter1){
counter1 = counter11;
counter11 = 1;
}
break;
}
}
}
function2(v2,n);
for(int x = 0;x<v.size();x++){
for(int i = x;i<v.size();i++){
if(i+1<n&&v2[i+1].hight>v2[i].hight){
counter22++;
}
else{
if(counter22>counter2){
counter2 = counter22;
counter22 = 1;
}
break;
}
}
}
int result = counter1>counter2 ? counter1:counter2;
cout<<result<<endl;
return 0;
}
// 通过了平台测试
/*
* at author FENGXIAOWEI
*/
#include<iostream>
#include<string>
using namespace std;
int main(){
int T;
cin>>T;
string str;
cin>>str;
int counter1,counter2 = 0;
if(T>1){
for(int x = 0;x<str.length()/2+1;x++){ // 依次给所选字串的长度值加一直到字符串长度的一半为止
for(int i = 0;i<str.length()-T+1;i++){
string tempt = str.substr(i,T);
counter1 = 1;
for(int k = i + 1;k<str.length()-T+1;k++){
string tempt2 = str.substr(k,T);
if(tempt2.compare(tempt)==0){
counter1++;
}
}
if(counter1>counter2){
counter2 = counter1;
}
}
T += 1;
}
cout<<counter2<<endl;
}
return 0;
}
using namespace std;int main(int argc, char* argv[])
{ int n=0;
int i=0;
int count=0;
//int qi[n][2];
int min[2]={1000000,1000000};
cin>>n;
int * qi=(int *)new int[n*2];
for(i=0;i<n;i++)
{
cin>>qi[2*i]>>qi[2*i+1];
if(min[0]>qi[2*i])
min[0] =qi[2*i];
//
}
for(i=0;i<n;i++)
{
if(qi[2*i]==min[0])
{
if(min[1]>qi[2*i+1])
{
min[1]=qi[2*i+1];
}
}
}
//min
for(i=0;i<n;i++)
{
if(qi[2*i]>=min[0] && qi[2*i+1]>=min[1])
count++;
}
cout<<count<<endl;return 0;
}
//请教大家,这题应该怎么做import java.util.*;
public class Main{
public static void main(String args[]) throws Exception {
Scanner cin=new Scanner(System.in);
int loop=cin.nextInt();
int[][] qq=new int[loop][2];
//输入
for(int i=0;i<loop;i++){
for(int j=0;j<2;j++){
qq[i][j]=cin.nextInt();
}
}
//step1获得权值矩阵
int[][] D=new int[loop][loop];
for(int i=0;i<loop;i++){
for(int j=0;j<loop;j++){
if((qq[i][0]>qq[j][0])&&(qq[i][1]>qq[j][1])){
D[i][j]= 1;
}else{
D[i][j]= 0;
}
}
}
//step2 floyd算法得到任意两点间的权值矩阵
int max=0;
for(int k=0;k<loop;k++){
for(int i=0;i<loop;i++){
if(D[k][i]>max){
max=D[k][i];
}
for(int j=0;j<loop;j++){
if((D[i][k]!=0)&&(D[k][j]!=0)&&(D[i][j]<(D[i][k]+D[k][j]))){
D[i][j]=D[i][k]+D[k][j];
}
}
}
}
System.out.println(max+1);
}}
呵呵,刚看到发帖时间,
怎么是比赛期间发的代码啊,
太强了!
你的代码通过测试了吗?
3
1 2
1 3
1 4
我也注册了
但有事没参加成
楼主,还有其他题目没啊??
我邮箱:[email protected]
谢谢!顶!