4

ChatGPT passed ABC280D under human coaching

 1 year ago
source link: http://codeforces.com/blog/entry/109815
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ChatGPT passed ABC280D under human coaching

By Lily, history, 36 hours ago,

ChatGPT is a NLP model released recently, and I found it unexpectedly strong. Here's the evidence.

The Problem : ABC 280 D

You are given an integer greater than or equal to . Find the minimum positive integer such that is a multiple of .

Here, denotes the factorial of . Under the Constraints of this problem, we can prove that such an always exists.

Constraint:

ChatGPT correct submission

Here are the interactions. ChatGPT spoke Chinese to me (which I didn't figure out how to configure it), so I'd provide some translations here.


Human: (The problem statement with hint to use long long)

ChatGPT: We can use code to implement the above algorithm. (Code follows)


Human: This code can not process the case when the factorials are large. You can enumarate the answer, and when newly add n to the factorial, the gcd(K, n) factor can be eliminated, until K = 1. Try to optimize your code.

ChatGPT: In order to solve the above problems, we can optimize the code to handle the case where the factorial is too large. We can use enumeration to find the smallest positive number N that satisfies the condition, and then offset the divisor of gcd (K, n) in K with the order n of N each time until K is 1.

The implementation is as follows. (Code follows)


Human: The code is slow when K has a large prime factor. You can factorize K firstly, if K has a prime factor no less than 1e6, then print it as the answer. Otherwise, we run the previous algorithm to solve the problem.

ChatGPT: In order to speed up the program, we can optimize it to handle the case when K has large prime factor. We can factorize K firstly, if K has a prime factor no less than 1e6, then print it as the answer. Otherwise, we run the previous algorithm. Here's the implementation. (Partial code)

Human: You didn't write code completely, please finish it.

ChatGPT: (More code)


Human: In the above code, you modified k in the factorizing, leading a wrong answer in the latter algorithm. Please copy k to a temporary variable in order to avoid affecting the original code.

ChatGPT: (Same comment, code)


Human: You should output n-1 instead of n.

ChatGPT: (Correct code)


Human: Thank you! Your code passed the problem.

ChatGPT: You're welcome, it's pleasure of mine. Let me know if you have any other questions. I will try my best to help you.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK