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

版权声明:本文为博主原创文章,转载请说明出处。 https://blog.csdn.net/xianpingping/article/details/82193105

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

猜你喜欢

转载自blog.csdn.net/xianpingping/article/details/82193105