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:


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

分析:结论就是ans=(a-1)*(b-1)

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
{
write(x/);
}
putchar(x%+'');
}
int main()
{
int a,b;
cin>>a>>b;
cout<<(a-)*(b-)<<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

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

分析:输出第一个,最后一个就好咯

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
{
write(x/);
}
putchar(x%+'');
}
char s[];
int main()
{
cin>>s;
int len=strlen(s);
cout<<s[]<<len-<<s[len-]<<endl;
return ;
}

C - 4-adjacent


Time limit : 2sec / Memory limit : 256MB

Score : 400 points

Problem Statement

We have a sequence of length N, a=(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

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

分析:统计4的倍数,2的倍数还有不是这两个的倍数的数,然后2个2的倍数等于4的倍数,然后就这样了!

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
{
write(x/);
}
putchar(x%+'');
}
int main()
{
int n;
cin>>n;
int a=,b=,c=;
for(int i=;i<n;i++)
{
ll x;
x=read();
if(x%==)
a++;
else if(x%==)
b++;
else c++;
}
if(b>)
c++;
if(a+>=c)
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 1, 2, , N. 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 i by 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

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

分析:从一个点可以到达其它所有的点,直接来一个水平填充好像就过了

下面给出AC代码:

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')
f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
inline void write(int x)
{
if(x<)
{
putchar('-');
x=-x;
}
if(x>)
{
write(x/);
}
putchar(x%+'');
}
int w,h,n;
int s[][];
int cnt[];
int main()
{
h=read();
w=read();
n=read();
for(int i=;i<=n;i++)
cnt[i]=read();
int k=;
for(int i=;i<=h;i++)
{
if(i%==)
{
for(int j=;j<=w;j++)
{
if(cnt[k]==)
k++;
cnt[k]--;
s[i][j]=k;
}
}
else
{
for(int j=w;j>;j--)
{
if(cnt[k]==)
k++;
cnt[k]--;
s[i][j]=k;
}
}
}
for(int i=;i<=h;i++)
{
for(int j=;j<=w;j++)
printf("%d ",s[i][j]);
printf("\n");
}
return ;
}

AtCoder Beginner Contest 069【A,水,B,水,C,数学,D,暴力】的更多相关文章

  1. AtCoder Beginner Contest 022 A.Best Body 水题

    Best Body Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://abc022.contest.atcoder.jp/tasks/abc02 ...

  2. AtCoder Beginner Contest 069 ABCD题

    题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...

  3. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  4. AtCoder Beginner Contest 153 题解

    目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...

  5. AtCoder Beginner Contest 223

    AtCoder Beginner Contest 223 A是纯纯的水题,就不说了 B - String Shifting 思路分析 我真的sb,一开始想了好久是不是和全排列有关,然后读了好几遍题目也 ...

  6. AtCoder Beginner Contest 184 题解

    AtCoder Beginner Contest 184 题解 目录 AtCoder Beginner Contest 184 题解 A - Determinant B - Quizzes C - S ...

  7. AtCoder Beginner Contest 148 题解

    目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...

  8. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  9. AtCoder Beginner Contest 053 ABCD题

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

随机推荐

  1. iOS 页面之间的专长动画控制器间的转换

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; line-height: 24.0px; font: 14.0px "Heiti SC Light" ...

  2. Android 再按一次退出程序三种办法

    在Xamarin android中双击返回键退出程序的第一种做法 思路就是当用户按下返回键的时间超过两秒就退出,根据Keycode.Back判断用户按下的是返回键,重写这个OnKeyDown Date ...

  3. RSA,DES,RC4,3DES ,MD5

    一,RSA算法基于一个十分简单的数论事实:将两个大质数相乘十分容易,但是想要对其乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥. RSA算法是一种非对称密码算法,所谓非对称,就是指该算法需 ...

  4. JS中数组的方法

    1. join() Array.join() 是 String.split() 的逆向操作 var arr = [1, 2, 3] arr.join()// "1,2,3" arr ...

  5. Zabbix自动发现java进程

    一:简介 使用Python psutil模块,查找java模块,并获取启动命令,结合zabbix监控自动监控.点击下载 二:操作 发现脚本 #!/usr/bin/env python # coding ...

  6. Linux并发连接上百万的配置

    To support over 500k users, you *need* - A bits hardware/kernel (AMD64, Opterons) - At least 8GB of ...

  7. Shader 1:能接受阴影的透明shader

    第一次接触Shader,项目需要,直接说需求吧,需要一个透明并且能接受阴影的shader.unity系统自带的shader已经满足不了了.上一段代码吧 Shader "GreenArch/T ...

  8. C# 全选中数字文本框内容

    /// <summary>        /// 全选中数字文本框内容        /// </summary>        /// <param name=&quo ...

  9. JS对时间的操作

    JS时间操作大全 1.获取每个月的开始和结束. 2.获取每个季度的开始和结束. 3.获取当前季度. 4.把日期转换为字符串(支持各种格式) ... 5.未完待续,不断添加 String.prototy ...

  10. iOS开发的另类神器:libimobiledevice开源包【类似android adb 方便获取iOS设备信息】

    简介 libimobiledevice又称libiphone,是一个开源包,可以让Linux支持连接iPhone/iPod Touch等iOS设备.由于苹果官方并不支持Linux系统,但是Linux上 ...