Solve AtCoder Beginner Contest 156 in java

AtCoder Beginner Contest 156 Thank you for your hard work! Official page

The code I wrote this time is here The result was AC from A to D, and E was able to AC 5 minutes after the end of the contest. Frustrating: cry:

I will explain briefly below.

Problem A

N and K are given as arguments, The problem of adding 100 * (10-K) to N when K is 10 or less.

I think it was a 100-point problem.

Problem B

The problem of outputting several digits when a certain number is in K notation. It's okay if you count the number of digits by turning around with a while statement.

while (n >= k) {
	n = n / k;
	digit++;
}

Problem C

There are N people on the number line, and the point to minimize the sum of squares of the distance traveled by all of them and the problem of finding the sum of squares. First, select the coordinates that will be the center of N people (note that they must be integers). After that, I simply added the sum of squares.

Since it was N <= 100, it seemed that I didn't have to worry too much about the amount of calculation.

Problem D

Binomial coefficient problem. It uses the following properties:

2^n = {}_n C _0 + {}_n C _1 + {}_n C _2 +・ ・ ・\\
    = \sum_{k=0}^n {}_n C _k\\

Then, what should be calculated is

2^n - {}_n C _0 - {}_n C _a - {}_n C _b

It will be.

Problem E

I found the law 10 minutes before the end, so the implementation was not in time, Originally I was in N rooms one by one, and I noticed that once one move occurred, some room became 0.

I calculated the combination when K rooms have 0 people. Then

{}_n C _k \times {}_{n-1} C _{n-1-k}

It will be. Specifically, in the case of n = 6, k = 2,

{}_6 C _2 \times {}_5 C _3

is. So, take this sum

\sum_{i=0}^k \left( {}_n C _k \times {}_{n-1} C _{n-1-k} \right)

is. When k = 1 and when k is large, another consideration was required, but the basics can be calculated above. I calculated the inverse element first and wrote the amount of calculation well, but it was a little more.

Problem F

It's untouched. I felt it was difficult because there were a lot of inputs, so I passed through. Lol


The rating is 944 → 974.

Overall it seems a little difficult. E The problem is a little more ... and I can't reach it. However, I was about to reach the E problem, so I got a sense of growth! Next time I want to do E problem AC ...!

Also, I wrote a mathematical formula using TeX. After all it is beautiful: chart_with_upwards_trend:

Recommended Posts

Solve AtCoder Beginner Contest 151 in java
Solve AtCoder Beginner Contest 150 in java
Solve AtCoder Beginner Contest 153 in java
Solve AtCoder Beginner Contest 175 in java
Solve AtCoder Beginner Contest 160 in java
Solve AtCoder Beginner Contest 152 in java
Solve AtCoder Beginner Contest 156 in java
AtCoder Beginner Contest 168
AtCoder Beginner Contest 167 C Problem (Java)
AtCoder Beginner Contest 182 Participation Article
AtCoder Beginner Contest 132 D Problem
java beginner 3
java beginner
AtCoder dwango Programming Contest B in Ruby, Perl and Java
AtCoder ARC 081 C hash to solve in Ruby, Perl and Java
Try to solve Project Euler in Java
Partization in Java
Sorting AtCoder ABC 111 C hashes to solve in Ruby, Perl and Java
Rock-paper-scissors in Java
Java Beginner Exercises
Pi in Java
FizzBuzz in Java
Java Exercise "Beginner"
AtCoder Beginner Contest 169 A, B, C with ruby
Basics of threads and Callable in Java [Beginner]
[AtCoder Problem-ABC001] C-Do wind observation in Java [Code]
How to solve an Expression Problem in Java
[Beginner] Install java development tool in cloud9 development environment.
A story about a super beginner participating in the AtCoder contest for the first time (AtCoder Beginner Contest 140)
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Make Blackjack in Java
Rock-paper-scissors app in Java
Constraint programming in Java
Put java8 in centos7
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
It's late! Try implementing Android Notification in Java (Beginner)
Azure functions in java
AtCoder Beginner Contest 170 A, B, C up to ruby
Simple htmlspecialchars in Java
Boyer-Moore implementation in Java
Hello World in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
ASCII art in Java
Compare Lists in Java
POST JSON in Java
Express failure in Java
Try to solve a restricted FizzBuzz problem in Java
Create JSON in Java
Date manipulation in Java 8
What's new in Java 8
Use PreparedStatement in Java
What's new in Java 9,10,11