Solve AtCoder Beginner Contest 152 in java

AtCoder Beginner Contest 152 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 WA from E.

I will explain briefly below.

Problem A

The problem of comparing the arguments N and M. If they are the same, output Yes, if they are different, output No.

Problem B

The problem of outputting which of the character string in which a is repeated b times and the character string in which b is repeated a times is faster in ** dictionary order **. Since it is in dictionary order, the smaller of a and b comes first.

If you can output a character string that repeats the smaller a and b for the larger a and b, it is AC.

Problem C

The explanation is a little difficult, but in the end it is OK if you answer how many times the minimum value was updated in the sequence. 4, 5, 2, 3, 1 In the above case, the number 3 in bold is the correct answer.

Problem D

Among the numbers below N,

--First number of A = Last number of B --First number of B = Last number of A

It is a question to answer how many combinations of numbers satisfy both of. I thought it wouldn't be in time if I had a double loop in the number of N, so

--Loop first to create a map of the first and last numbers --In the second loop, get the numbers that match the conditions and add them together.

It was made. Personally, I was happy to realize that I had to change my policy because I couldn't make it in time for the calculation.

Problem E

AiBi = AjBj holds for any i, j. In other words, the problem of finding the least common multiple and dividing by Ai to find Bi.

The answer is to add them together and output.

I understand the part that decides the policy, and if I use the inverse element that I studied recently, it will break with Ai! It was good up to that point, It doesn't work well for large numbers. I was able to identify the cause.

When calculating the least common multiple, it was a large number, and once divided by 1000000007, the least common multiple could not be calculated correctly. As a result of various thoughts, it could not be resolved. ..

I thought about holding the least common multiple in the explanation in the form of prime factorization, but I couldn't make it into a code due to lack of ability. (I haven't got an image of what to do yet, so I'll think about it again at the end of work on weekdays.)

Problem F

I feel that problem E can be done soon, so I haven't touched it. ..

The rating is 897 → 956. The best update!

I was able to reach the D problem in 25 minutes, and I felt growth. I came up with the idea of using the inverse element of the E problem, but I'm very disappointed that I haven't taken a step further. ..

Next time I want to put learning into shape ...: sunny:

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 4
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
Changes in Java 11
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
[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
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
Comments in Java source
Format XML 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
Use OpenCV in Java
webApi memorandum in java
Type determination in Java
Ping commands in Java
Various threads in java
Heapsort implementation (in java)
Zabbix API in Java
ASCII art in Java
Compare Lists 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