Codeforces Beta Round #65 (Div. 2)——A,B,C

A. Way Too Long Words
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.

Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.

This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.

Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".

You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.

Input

The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.

Output

Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        string s;
        cin>>s;
        int L=s.size();
        if(L<=10) cout<<s<<endl;
        else cout<<s[0]<<L-2<<s[L-1]<<endl;
    }
    return 0;
}



B. Progress Bar
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A progress bar is an element of graphical interface that displays the progress of a process for this very moment before it is completed. Let's take a look at the following form of such a bar.

A bar is represented as n squares, located in line. To add clarity, let's number them with positive integers from 1 to n from the left to the right. Each square has saturation (ai for the i-th square), which is measured by an integer from 0 to k. When the bar for some i (1 ≤ i ≤ n) is displayed, squares 1, 2, ... , i - 1 has the saturation k, squares i + 1, i + 2, ... , n has the saturation 0, and the saturation of the square i can have any value from 0 to k.

So some first squares of the progress bar always have the saturation k. Some last squares always have the saturation 0. And there is no more than one square that has the saturation different from 0 and k.

The degree of the process's completion is measured in percents. Let the process be t% completed. Then the following inequation is fulfilled:

An example of such a bar can be seen on the picture.

For the given nkt determine the measures of saturation for all the squares ai of the progress bar.

Input

We are given 3 space-separated integers nkt (1 ≤ n, k ≤ 1000 ≤ t ≤ 100).

Output

Print n numbers. The i-th of them should be equal to ai.

#include <iostream>
using namespace std;
int main()
{
    int n,k,t;
    cin>>n>>k>>t;
    //sum为Ai的和式的下界
    int sum=t*n*k/100;
    int cnt=sum/k;
    for(int i=0;i<cnt;i++)//先填cnt个k
        cout<<k<<" ";
   if(cnt<n)
   {
       int p=sum-cnt*k;//补上差值
       cout<<p;
       for(int i=0;i<n-cnt-1;i++)//剩下的补0
        cout<<" 0";
   }
    cout<<endl;
    return 0;
}

C. Round Table Knights
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are n knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.

Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights in a good mood should be located. Otherwise, the next month will bring misfortunes.

A convex polygon is regular if all its sides have same length and all his angles are equal. In this problem we consider only regular polygons with at least 3 vertices, i. e. only nondegenerated.

On a picture below some examples of such polygons are present. Green points mean knights in a good mood. Red points mean ones in a bad mood.

King Arthur knows the knights' moods. Help him find out if the next month will be fortunate or not.

Input

The first line contains number n, which is the number of knights at the round table (3 ≤ n ≤ 105). The second line contains space-separated moods of all the n knights in the order of passing them around the table. "1" means that the knight is in a good mood an "0" means that he is in a bad mood.

Output

Print "YES" without the quotes if the following month will turn out to be lucky. Otherwise, print "NO".

#include <iostream>
#include <cstring>
using namespace std;
const int maxn =100000+5;
bool m[maxn];
int a[maxn];
int main()
{
    int n,sum=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n==sum)//全为1的特判
    {
        cout<<"YES"<<endl;
        return 0;
    }
    bool flag=false;
    for(int t=3; t<=n; t++)
        if(n%t==0)//此处可以加个素数的判断
        {
            memset(m,0,sizeof(m));
            for(int i=1; i<=n/t; i++)
            {
                if(a[i]==1)
                {
                    for(int j=i; j<=n; j+=n/t)
                        if(a[i]+a[j]!=2) m[i]=1;
                }
                else m[i]=1;
            }
            int cnt=0;
            for(int i=1; i<=n/t; i++)
                if(!m[i]) cnt++;
            if(cnt) flag=true;
        }
    if(flag) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值