题目链接:http://abc069.contest.atcoder.jp/assignments

A - K-City


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

In K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?

Constraints

  • 2≤n,m≤100

Input

Input is given from Standard Input in the following format:

n m

Output

Print the number of blocks in K-city.


Sample Input 1

Copy
3 4

Sample Output 1

Copy
6

There are six blocks, as shown below:


Sample Input 2

Copy
2 2

Sample Output 2

Copy
1

There are one block, as shown below:

题解:水题
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int main()
{
int n,m;
while(cin>>n>>m){
cout<<(n-)*(m-)<<endl;
}
return ;
}

B - i18n


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

The word internationalization is sometimes abbreviated to i18n. This comes from the fact that there are 18 letters between the first i and the last n.

You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.

Constraints

  • 3≤|s|≤100 (|s| denotes the length of s.)
  • s consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s

Output

Print the abbreviation of s.


Sample Input 1

Copy
internationalization

Sample Output 1

Copy
i18n

Sample Input 2

Copy
smiles

Sample Output 2

Copy
s4s

Sample Input 3

Copy
xyz

Sample Output 3

Copy
x1z

题解:水题

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
int main()
{
string a;
while(cin>>a){
int len=a.length();
cout<<a[]<<len-<<a[len-]<<endl;
}
return ;
}

C - 4-adjacent


Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

We have a sequence of length Na=(a1,a2,…,aN). Each ai is a positive integer.

Snuke's objective is to permute the element in a so that the following condition is satisfied:

  • For each 1≤iN−1, the product of ai and ai+1 is a multiple of 4.

Determine whether Snuke can achieve his objective.

Constraints

  • 2≤N≤105
  • ai is an integer.
  • 1≤ai≤109

Input

Input is given from Standard Input in the following format:

N
a1 a2 aN

Output

If Snuke can achieve his objective, print Yes; otherwise, print No.


Sample Input 1

Copy
3
1 10 100

Sample Output 1

Copy
Yes

One solution is (1,100,10).


Sample Input 2

Copy
4
1 2 3 4

Sample Output 2

Copy
No

It is impossible to permute a so that the condition is satisfied.


Sample Input 3

Copy
3
1 4 1

Sample Output 3

Copy
Yes

The condition is already satisfied initially.


Sample Input 4

Copy
2
1 1

Sample Output 4

Copy
No

Sample Input 5

Copy
6
2 7 1 8 2 8

Sample Output 5

Copy
Yes

题解:找出4和2的倍数即可

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
const int N=;
int a[N];
int main()
{
int n;
cin>>n;
int t1=,t2=;
for(int i=;i<n;i++){
cin>>a[i];
if(a[i]%==)
t1++;
else if(a[i]%==)
t2++;
}
int flag=;
int m;
if(t2%==) m=t2;
else m=t2-;
if((n-m)/<=t1)flag=;
if(flag) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return ;
}

D - Grid Coloring


Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 12N. Here, the following conditions should be satisfied:

  • For each i (1≤iN), there are exactly ai squares painted in Color i. Here, a1+a2+…+aN=HW.
  • For each i (1≤iN), the squares painted in Color i are 4-connected. That is, every square painted in Color i can be reached from every square painted in Color iby repeatedly traveling to a horizontally or vertically adjacent square painted in Color i.

Find a way to paint the squares so that the conditions are satisfied. It can be shown that a solution always exists.

Constraints

  • 1≤H,W≤100
  • 1≤NHW
  • ai≥1
  • a1+a2+…+aN=HW

Input

Input is given from Standard Input in the following format:

H W
N
a1 a2 aN

Output

Print one way to paint the squares that satisfies the conditions. Output in the following format:

c11  c1W
:
cH1 cHW

Here, cij is the color of the square at the i-th row from the top and j-th column from the left.


Sample Input 1

Copy
2 2
3
2 1 1

Sample Output 1

Copy
1 1
2 3

Below is an example of an invalid solution:

1 2
3 1

This is because the squares painted in Color 1 are not 4-connected.


Sample Input 2

Copy
3 5
5
1 2 3 4 5

Sample Output 2

Copy
1 4 4 4 3
2 5 4 5 3
2 5 5 5 3

Sample Input 3

Copy
1 1
1
1

Sample Output 3

Copy
1

题解:看半天不懂撒意思 题解说是蛇形填数

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int r,c,n,x,y,ans[][];
int main(void)
{
scanf("%d%d%d",&r,&c,&n);
x=,y=;
for(int i=,cnt;i<=n;i++){
scanf("%d",&cnt);
while(cnt--){
ans[x][y]=i;
if(y==c&&x%==)
y=c,x++;
else if(y==&&x%==)
y=,x++;
else if(x&)
y++;
else
y--;
}
}
for(int i=;i<=r;i++)
for(int j=;j<=c;j++)
printf("%d%c",ans[i][j],j==c?'\n':' ');
return ;
}

AtCoder Beginner Contest 069 ABCD题的更多相关文章

  1. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  2. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  3. AtCoder Beginner Contest 070 ABCD题

    题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...

  4. AtCoder Beginner Contest 057 ABCD题

    A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...

  5. AtCoder Beginner Contest 051 ABCD题

    A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...

  6. AtCoder Beginner Contest 052 ABCD题

    A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...

  7. AtCoder Beginner Contest 054 ABCD题

    A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...

  8. AtCoder Beginner Contest 058 ABCD题

    A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...

  9. AtCoder Beginner Contest 050 ABC题

    A - Addition and Subtraction Easy Time limit : 2sec / Memory limit : 256MB Score : 100 points Proble ...

随机推荐

  1. SVN安装部署

    svn安装版本用的是1.8 SVN属于功能性软件,yum安装即是最佳实践. 安装svn yum install subversion 检查svn是否安装完毕 [root@mysql ~]# rpm - ...

  2. 一、程序设计与C语言

    @程序:用特殊的编程语言编写的代码,用于表达如何解决问题. @编程语言的作用:编程语言不是用来和计算机交谈的,而是用它来描述要求计算机如何解决问的过程或方法.计算机只能执行(懂得)机器语言. @辗转相 ...

  3. docker容器多服务(不推荐)

    1.最常用方式配置进程管理工具Supervisor 2.最简单的就是把多个启动命令放到一个启动脚本里面,启动的时候直接启动这个脚本 第一种方式: 1.构建基础镜像 FROM lmurawsk/pyth ...

  4. tf运作方式之共享变量

    转自:https://docs.pythontab.com/tensorflow/how_tos/variable_scope/ 这个讲的不错,能够更理解tf.get_Variable()了.创建时有 ...

  5. git issue 汇总

    (1)部分: https://wiki.mahara.org/wiki/Developer_Area/Contributing_Code/Troubleshooting_your_Gerrit_con ...

  6. 分享一个.NET(C#)按指定字母个数截断英文字符串的方法–提供枚举选项,可保留完整单词

    分享一个.NET(C#)按字母个数截断英文字符串的方法,该方法提供枚举选项.枚举选项包括:可保留完整单词,允许最后一个单词超过最大长度限制,字符串最后跟省略号以及不采取任何操作等,具体示例实现代码如下 ...

  7. plt.contour 与 plt.contourf

    contour:轮廓,等高线 1.为等高线上注明等高线的含义: cs = plt.contour(x, y, z) plt.clabel(cs, inline=True, fontsize=10)#i ...

  8. apache分割数组和集合的分法

    public static void main(String[] agrs){    String[] array={"1","2","", ...

  9. ida pro 使用

    交互式反汇编器专业版(Interactive Disassembler Professional),人们常称其为IDA Pro,或简称为IDA.是目前最棒的一个静态反编译软件,为众多0day世界的成员 ...

  10. 从零开始一起学习SLAM | 不推公式,如何真正理解对极约束?

    自从小白向师兄学习了李群李代数和相机成像模型的基本原理后,感觉书上的内容没那么难了,公式推导也能推得动了,感觉进步神速,不过最近小白在学习对极几何,貌似又遇到了麻烦... 小白:师兄,对极几何这块你觉 ...