zhejiang省赛热身赛之---周赛第二场

                                                     Accurately Say "CocaCola"!
Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 25   Accepted Submission(s) : 8
Problem Description
              In a party held by CocaCola company, several students stand in a circle and play a game.

  One of them is selected as the first, and should say the number 1. Then they continue to count number from 1 one by one (clockwise). The game is interesting in that, once someone counts a number which is a multiple of 7 (e.g. 7, 14, 28, ...) or contains the digit '7' (e.g. 7, 17, 27, ...), he shall say "CocaCola" instead of the number itself.

  For example, 4 students play this game. At some time, the first one says 25, then the second should say 26. The third should say "CocaCola" because 27 contains the digit '7'. The fourth one should say "CocaCola" too, because 28 is a multiple of 7. Then the first one says 29, and the game goes on. When someone makes a mistake, the game ends.

  During a game, you may hear a consecutive of p "CocaCola"s. So what is the minimum number that can make this situation happen?

  For example p = 2, that means there are a consecutive of 2 "CocaCola"s. This situation happens in 27-28 as stated above. 27 is then the minimum number to make this situation happen.

  Input

  Standard input will contain multiple test cases. The first line of the input is a single integerT (1 <= T <= 100) which is the number of test cases. And it will be followed byT consecutive test cases.

  There is only one line for each case. The line contains only one integer p (1 <= p <= 99).

  Output

  Results should be directed to standard output. The output of each test case should be a single integer in one line, which is the minimum possible number for the first of thep "CocaCola"s stands for.

  Sample Input

2
2
3

  Sample Output

27
70


Source
The 5th Zhejiang Provincial Collegiate Programming Contest

 代码:

#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;//头文件
int main()
{
	int cas;
	int n;
	cin>>cas;
	int num=0;
	while(cas--)
	{
		cin>>n;
	  
		if(n==1)
		num=7;
		else if(n==2)
		num=27;
		else if(n>=3&&n<=10)
		num=70;
    	else 	if(n==11)
		num=270;
	   else	
	     num=700;
	     
		cout<<num<<endl;
	}
	return 0;
}
 


Build The Electric System

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 3   Accepted Submission(s) : 3
Problem Description

In last winter, there was a big snow storm in South China. The electric system was damaged seriously.  Lots of power lines were broken and lots of villages lost contact with the main power grid.  The government wants to reconstruct the electric system as soon as possible.  So, as a professional programmer, you are asked to write a program to calculate the minimum cost to reconstruct the power lines to make sure there's at least one way between every two villages.

Input

Standard input will contain multiple test cases. The first line of the input is a single integerT (1 <= T <= 50) which is the number of test cases. And it will be followed byT consecutive test cases.

In each test case, the first line contains two positive integers N andE (2 <= N <= 500, N <= E <= N * (N - 1) / 2), representing the number of the villages and the number of the original power lines between villages.  There followE lines, and each of them contains three integers, A, B,K (0 <= A, B < N, 0 <= K < 1000). A and B respectively means the index of the starting village and ending village of the power line.  IfK is 0, it means this line still works fine after the snow storm. If K is a positive integer, it means this line will cost K to reconstruct. There will be at most one line between any two villages, and there will not be any line from one village to itself.

Output

For each test case in the input, there's only one line that contains the minimum cost to recover the electric system to make sure that there's at least one way between every two villages.

Sample Input

1
3 3
0 1 5
0 2 0
1 2 9

Sample Output

5


 

Source

The 5th Zhejiang Provincial Collegiate Programming Contest

 code:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
#define inf 1000111222
#define N  3009
int n,m;        ///n--节点数,  m--边数
int G[N][N];      ///邻接矩阵存储图的信息
int dis[N];     ///距离
bool used[N];   ///标记某个点是否已经被使用过
void prim()
{
    int i,j,start=0,ans=0,minD,which;   ///认为起点是 1
    fill(dis, dis+N, inf);      ///所有距离初始化为无穷大
    dis[start]=0;    ///起点的距离为 0
    memset(used, false, sizeof(used));  ///所有点都未被使用过
    for(i=0;i < n;i++)     /// n 次
    {
        minD = inf;
        for(j=0;j < n;j++)
            if(!used[j] && minD >= dis[j])  ///找最小的且没有使用过的点
            {
                minD = dis[j];
                which = j;
            }
        used[which] = true;     ///标记为使用过
        ans += dis[which];  /// ans += minD;
        for(j=0;j < n;j++)
            if(dis[j] > G[which][j])    ///更新dis值
                dis[j] = G[which][j];
    }
   //printf("the min total len is %d\n",ans);
   printf("%d\n",ans);
}
int main()
{
    int i,j,st,en,len;
    int m;
    int cas;
    cin>>cas;
    while(cas--)
    {
    	
       cin>>n>>m;
      
        for(i=0;i < n;i++)
            for(j=0;j < n;j++)
                G[i][j] = inf;  ///初始化所有距离为无穷大
        while(m--)
        {
            scanf("%d %d %d",&st,&en,&len);
            
            if(st != en && G[st][en] > len) ///去除重边和自环!!!!
                G[st][en] = G[en][st] = len;    ///无向图
        }
        prim();
      
    }
    return 0;
}


Easy Task

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 11   Accepted Submission(s) : 7
Problem Description

            Calculating the derivation of a polynomial is an easy task. Given a function f(x) , we use (f(x))' to denote its derivation. We use x^n to denote x n. To calculate the derivation of a polynomial, you should know 3 rules:
(1) (C)'=0    where C is a constant.
(2) (Cx^n)'=C*n*x^(n-1) where n>=1 and C is a constant. 
(3) (f1(x)+f2(x))'=(f1(x))'+(f2(x))'.
It is easy to prove that the derivation a polynomial is also a polynomial.

Here comes the problem, given a polynomial f(x) with non-negative coefficients, can you write a program to calculate the derivation of it?

Input

Standard input will contain multiple test cases. The first line of the input is a single integerT (1 <= T <= 1000) which is the number of test cases. And it will be followed byT consecutive test cases.

There are exactly 2 lines in each test case. The first line of each test case is a single line containing an integerN (0 <= N <= 100).  The second line contains N + 1 non-negative integers,CN, CN-1, ...,C1, C0, ( 0 <=Ci <= 1000), which are the coefficients of f(x).Ci is the coefficient of the term with degreei in f(x). (CN!=0)

Output

For each test case calculate the result polynomial g(x) also in a single line.
(1) If g(x) = 0 just output integer 0.otherwise 
(2) suppose g(x)= Cmx^m+Cm-1x^(m-1)+...+C0 (Cm!=0),then output the integers Cm,Cm-1,...C0.
(3) There is a single space between two integers but no spaces after the last integer.

Sample Input

3
0
10
2
3 2 1
3
10 0 1 2

Sample Output

0
6 2
30 0 1


 

Source

The 5th Zhejiang Provincial Collegiate Programming Contest

 

#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

int xishu[1005];
int op[1005];

int main()
{
	int testcase;
	cin>>testcase;
	for(int i=0;i<testcase;i++)
	{
		memset(xishu,0,sizeof(xishu));
		memset(op,0,sizeof(op));
		int cishu,total;
		cin>>cishu;
		if(cishu==0)
		{
			int a;
			cin>>a;
			cout<<"0"<<endl;
		}
		else
		{
		total=cishu;
		for(int i=0;i<=cishu;i++)
		{
			cin>>xishu[i];
			op[i]=xishu[i]*total;
			total--;
		}
		
		for(int j=0;j<cishu;j++)
		{
			if(j!=cishu-1)
			{
				cout<<op[j]<<" ";
			}
			else
			{
				cout<<op[j]<<endl;
			}
		}
		
		}
		
	}
	
	return 0;
}


 Give Me the Number
Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 9   Accepted Submission(s) : 2
Problem Description
            Numbers in English are written down in the following way (only numbers less than 109 are considered). Number abc,def,ghi is written as " [abc] million [def] thousand [ghi]". Here " [xyz] " means the written down number xyz

In the written down number the part "[abc] million" is omitted  if abc = 0 , "[def] thousand" is omitted if def = 0 , and "[ghi] " is omitted ifghi = 0 .  If the whole number is equal to 0 it is written down as "zero". Note that words "million" and "thousand" are singular even if the number of millions or thousands respectively is greater than one.

Numbers under one thousand are written down in the following way. The numberxyz is written as "[x] hundred and[yz] ”. ( If yz = 0 it should be only “[x] hundred”. Otherwise ify = 0 it should be only “[x] hundred and [z]”.) Here "[x] hundred and" is omitted ifx = 0 . Note that "hundred" is also always singular.

Numbers under 20 are written down  as  "zero",  "one",  "two",  "three",  "four",  "five",  "six", "seven",  "eight",  "nine",  "ten",  "eleven",  "twelve",  "thirteen", "fourteen",  "fifteen",  "sixteen",  "seventeen",  "eighteen", and  "nineteen" respectively.  Numbers from 20 to 99 are written down in the following way. Numberxy is written as "[x0] [y] ", and numbers divisible by ten are written as  "twenty",  "thirty",  "forty",  "fifty",  "sixty",  "seventy", "eighty", and  "ninety"  respectively.

For example, number 987,654,312 is written down as "nine hundred and eighty seven million six hundred and fifty four thousand three hundred and twelve", number100,000,037 as "one hundred million thirty seven", number 1,000as "one thousand". Note that "one" is never omitted for millions, thousands and hundreds.

Give you the written down words of a number, please give out the original number.

Input

Standard input will contain multiple test cases. The first line of the input is a single integerT (1 <= T <= 1900) which is the number of test cases. It will be followed byT consecutive test cases.

Each test case contains only one line consisting of a sequence of English words representing a number.

Output

For each line of the English words output the corresponding integer in a single line. You can assume that the integer is smaller than109.

Sample Input

3
one
eleven
one hundred and two

Sample Output

1
11
102


Source
The 5th Zhejiang Provincial Collegiate Programming Contest
 
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
using namespace std;//头文件
 
map<string,int> pack;
void init()
{
//	pack["hundred"]=100;
//	pack["million"]=1000000;
//	pack["thousand"]=1000;
    pack["one"]=1;
    pack["two"]=2;
    pack["three"]=3;
    pack["four"]=4;
    pack["five"]=5;
    pack["six"]=6;
    pack["seven"]=7;
    pack["eight"]=8;
    pack["nine"]=9;
    pack["ten"]=10;
    pack["eleven"]=11;
    pack["twelve"]=12;
    pack["thirteen"]=13;
    pack["fourteen"]=14;
    pack["fifteen"]=15;
    pack["sixteen"]=16;
    pack["seventeen"]=17;
    pack["eighteen"]=18;
    pack["nineteen"]=19;
    pack["twenty"]=20;
    pack["thirty"]=30;
    pack["forty"]=40;
    pack["fifty"]=50;
    pack["sixty"]=60;
    pack["seventy"]=70;
    pack["eighty"]=80;
    pack["ninety"]=90;
}
int main()
{
    int testcase;
    cin>>testcase;
    init();
    getchar();
    while (testcase--)
    {
        map<string,int>::iterator it;
        string tar[1005];
        char s1[1005];
        int k=0;
        int sum=0,tmp=0;
        int flaghundred=0;
        int flagmillion=0;
        int flagthousand=0;
        int thou=0;
        int mill=0;
        cin.getline(s1,1005,'\n');
        int len=strlen(s1);
        for (int i=0;i<len;i++)
        {
            if (s1[i]==' '||i==len)
            {
                k++;
                continue;
            }
            tar[k]+=s1[i];
        }
        
        for ( int i=0;i<=k;i++)
        {
            if (tar[i]=="and")
                continue;
            if ( tar[i]=="hundred")
                flaghundred=1;
            else if (tar[i]=="million")
                flagmillion=1;
            else if (tar[i]=="thousand")
                flagthousand=1;

            for (it=pack.begin();it!=pack.end();it++)
            {
                if ((it->first)==tar[i])
                {
                    tmp=(it->second);
                    break;
                }

            }
            if (flagmillion==1)
            {
                mill=sum;                
                tmp=0;
                sum=0;
                flagmillion=0;
                continue;

            }
            if (flagthousand==1)
            {
                thou=sum;               
                tmp=0;
                sum=0;
                flagthousand=0;
                continue;
            }
            if (flaghundred==1)
            {
                tmp=tmp*100;
                sum=0;

                flaghundred=0;
            }
            sum+=tmp;
           
        }
        if (mill!=0&&thou!=0&&sum!=0)
            cout<<mill*1000000+1000*thou+sum<<endl;
        if (mill!=0&&thou!=0&&sum==0)
            cout<<mill*1000000+1000*thou<<endl;
        if (mill!=0&&thou==0&&sum!=0)
            cout<<mill*1000000+sum<<endl;
        if (mill!=0&&thou==0&&sum==0)
            cout<<mill*1000000<<endl;
        if (mill==0&&thou!=0&&sum!=0)
            cout<<thou*1000+sum<<endl;
        if (mill==0&&thou!=0&&sum==0)
            cout<<thou*1000<<endl;
        if (mill==0&&thou==0)
            cout<<sum<<endl;     

        mill=0;
        thou=0;
        sum=0;

    }

    return 0;
}
 
 
                                                             Faster, Higher, Stronger
Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 23   Accepted Submission(s) : 8
Problem Description

In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China and Beijing Olympics is to be a festival for people all over the world as well.

The motto of Olympic Games is "Citius, Altius, Fortius", which means "Faster, Higher, Stronger".

In this problem, there are some records in the Olympic Games. Your task is to find out which one is faster, which one is higher and which one is stronger.

Input

Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 50) which is the number of test cases. And it will be followed by T consecutive test cases.

Each test case has 3 lines. The first line is the type of the records, which can only be "Faster" "Higher" or "Stronger".  The second line is a positive integer N meaning the number of the records in this test case.  The third line has N positive integers, i.e. the records data. All the integers in this problem are smaller than 2008.

Output

Results should be directed to standard output. The output of each test case should be a single integer in one line.  If the type is "Faster", the records are time records and you should output the fastest one.  If the type is "Higher", the records are length records. You should output the highest one.  And if the type is "Stronger", the records are weight records. You should output the strongest one.

Sample Input

3
Faster
3
10 11 12
Higher
4
3 5 4 2
Stronger
2
200 200

Sample Output

10
5
200


Source
The 5th Zhejiang Provincial Collegiate Programming Contest
 
 
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;//头文件
int cmp1(int a,int b)
{
	return a<b;
}
int cmp2(int a,int b)
{
	return a>b;
}
int main()
{
	int cas;
	cin>>cas;
	char ch[3000];
	int flag;
	int n;
	int num[3000];
	while(cas--)
	{
	    flag=0;	
		cin>>ch;
		if(ch[0]=='F')
		flag=1;
		else
		flag=2;
		
		cin>>n;
		for(int i=0;i<n;i++)
		{
			cin>>num[i];
		}
		if(flag==1)
		sort(num,num+n,cmp1);
		if(flag==2)
		sort(num,num+n,cmp2);
		
		cout<<num[0]<<endl;
	}
	return 0;
} 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值