AIM Tech Round 5 (rated, Div. 1 + Div. 2) abc

A. Find Square

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Consider a table of size n×m

, initially fully white. Rows are numbered 1 through n from top to bottom, columns 1 through m

from left to right. Some square inside the table with odd side length was painted black. Find the center of this square.

Input

The first line contains two integers n

and m (1≤n,m≤115

) — the number of rows and the number of columns in the table.

The i

-th of the next n lines contains a string of m characters si1si2…sim (sij is 'W' for white cells and 'B' for black cells), describing the i

-th row of the table.

Output

Output two integers r

and c (1≤r≤n, 1≤c≤m

) separated by a space — the row and column numbers of the center of the black square.

Examples

Input

Copy

5 6
WWBBBW
WWBBBW
WWBBBW
WWWWWW
WWWWWW

Output

Copy

2 4

Input

Copy

3 3
WWW
BWW
WWW

Output

Copy

2 1

思路:找到第一个B和最后一个B。分别保存下横纵坐标,加起来/2就可以了。

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    char ch;
    int I,J;
    int II,JJ;
    int lala=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>ch;
            if( ch=='B' && lala==0 ){
                I=i;
                J=j;
                lala=100;
            }
            if(ch=='B'){
                II=i;
                JJ=j;
            }
        }
    }
   /// cout<<II<<"  "<<JJ<<endl;
    ///cout<<I<<"  **  "<<J<<endl;
    int a=(I+II)/2;
    int b=(J+JJ)/2;
    cout<<a<<" "<<b<<endl;
    return 0;
}

B:

这道题还是比较考虑思维的。

http://codeforces.com/contest/1028/problem/B

B. Unnatural Conditions

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Let s(x)

be sum of digits in decimal representation of positive integer x. Given two integers n and m, find some positive integers a and b

such that

  • s(a)≥n
  • ,
  • s(b)≥n
  • ,
  • s(a+b)≤m
  • .

Input

The only line of input contain two integers n

and m (1≤n,m≤1129

).

Output

Print two lines, one for decimal representation of a

and one for decimal representation of b. Both numbers must not contain leading zeros and must have length no more than 2230

.

Examples

Input

Copy

6 5

Output

Copy

6 
7

Input

Copy

8 16

Output

Copy

35 
53

Note

In the first sample, we have n=6

and m=5. One valid solution is a=6, b=7. Indeed, we have s(a)=6≥n and s(b)=7≥n, and also s(a+b)=s(13)=4≤m.

思路:构造。

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
  ///  scanf("%d%d",&n,&m);
    for(int i=1;i<=1129;i++){
        cout<<1;
    }
    cout<<endl;
    for(int i=1;i<=1128;i++){
        cout<<8;
    }
    cout<<9<<endl;
    return 0;
}

C:https://blog.csdn.net/xianpingping/article/details/82193032

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值