| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python # YOUR CODE HERE import sys def find_nth_good_integer(N): digits = '02468' nth_good_integer = '' N -= 1 while N > 0: nth_good_integer = digits[N % 5] + nth_good_integer N //= 5 if nth_good_integer == '': nth_good_integer = '0' return nth_good_integer if __name__ == "__main__": input = sys.stdin.read data = input().strip() N = int(data) print(find_nth_good_integer(N)) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| deepseek-r1 | ```python n = int(input()) if n == 0: print(0) else: m = n - 1 digits = [] if m == 0: digits = [0] else: while m > 0: digits.append(m % 5) m = m // 5 digits = digits[::-1] s = ''.join(str(d * 2) for d in digits) print(s) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE N = int(input()) n = N - 1 digits = [] while n > 0: digits.append(n % 5) n //= 5 if not digits: digits = [0] digits = digits[::-1] # Reverse the digits to get the correct order mapped_digits = [] for d in digits: if d == 0: mapped_digits.append('0') elif d == 1: mapped_digits.append('2') elif d == 2: mapped_digits.append('4') elif d == 3: mapped_digits.append('6') elif d == 4: mapped_digits.append('8') result = int(''.join(mapped_digits)) print(result) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| gpt-4o-2024-08-06 | ```python # YOUR CODE HERE def find_nth_good_integer(N): # The digits we can use in a good integer even_digits = ['0', '2', '4', '6', '8'] # We will use a base-5 system where each digit is one of the even digits # Convert N to a base-5 number base_5_representation = [] while N > 0: N, remainder = divmod(N - 1, 5) base_5_representation.append(remainder) # Convert the base-5 representation to a good integer good_integer = ''.join(even_digits[d] for d in reversed(base_5_representation)) return good_integer import sys input = sys.stdin.read N = int(input().strip()) print(find_nth_good_integer(N)) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python # YOUR CODE HERE def is_good_integer(num): return all(digit in '02468' for digit in str(num)) def nth_good_integer(N): count = 0 num = 0 while True: if is_good_integer(num): count += 1 if count == N: return num num += 1 # Read input from stdin import sys input = sys.stdin.read N = int(input().strip()) # Output the result print(nth_good_integer(N)) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python import sys def solve(N): res = [] while N: res.append(str(N % 5 * 2)) N //= 5 return ''.join(res[::-1]) def main(): N = int(sys.stdin.readline().strip()) print(solve(N-1)) if __name__ == '__main__': main() ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python import sys def solve(): n = int(sys.stdin.readline()) ans = [] while n > 0: n, r = divmod(n - 1, 5) ans.append(str(r * 2)) print(''.join(reversed(ans))) if __name__ == '__main__': solve() ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| Qwen2-72B-Instruct | ```python from math import log10 def next_good_integer(n): str_n = str(n) len_n = len(str_n) if '1' in str_n or '3' in str_n or '5' in str_n or '7' in str_n or '9' in str_n: # If n contains any odd digit, find the next good integer for i in range(len_n - 1, -1, -1): if str_n[i] in "13579": # Increase the current digit by 1 if it's odd new_digit = str((int(str_n[i]) + 1) % 10) # Replace all digits after the current one with '0' return int(str_n[:i] + new_digit + '0' * (len_n - i - 1)) # If the highest digit is odd, prepend '2' and append '0's return int('2' + '0' * len_n) else: # If n is already a good integer, find the next one for i in range(len_n - 1, -1, -1): if str_n[i] != '8': # Increase the current digit by 2 if it's less than 8 new_digit = str((int(str_n[i]) + 2) % 10) # Replace all digits after the current one with '0' return int(str_n[:i] + new_digit + '0' * (len_n - i - 1)) # If the highest digit is 8, prepend '2' and append '0's return int('2' + '0' * len_n) def nth_good_integer(N): # The first good integer good_int = 0 # The number of good integers found so far count = 1 while count < N: good_int = next_good_integer(good_int) count += 1 return good_int N = int(input()) print(nth_good_integer(N)) ``` This solution calculates the N-th smallest good integer by iteratively finding the next good integer until it reaches the desired position. It handles cases where the current integer is not a good integer by increasing the first odd digit or the last even digit by a necessary amount and setting all following digits to zero. This process ensures that the resulting integer is the smallest possible good integer greater than the current one. |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| baichuan4 | ```python # YOUR CODE HERE def find_nth_good_integer(N): if N == 1: return 0 # The sequence of good integers starts with 0, then 2, 4, 6, 8, and so on. # After 0, the sequence can be seen as a combination of 2, 4, 6, 8 in each digit place. # We can construct the sequence by placing these digits in each place and counting up. # Start with the smallest good integer after 0, which is 2 current_good_integer = 2 # We need to find the (N-1)th good integer since we've already accounted for 0 for _ in range(N - 1): # Increment the current good integer current_good_integer += 2 # Only even numbers are allowed # Check if the incremented number is still a good integer while not is_good_integer(current_good_integer): current_good_integer += 2 # If not, keep incrementing by 2 until it is return current_good_integer def is_good_integer(n): # Check if all digits in the number are even while n > 0: digit = n % 10 if digit % 2 != 0: return False n //= 10 return True # Read input from stdin N = int(input().strip()) # Find and print the N-th smallest good integer print(find_nth_good_integer(N)) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| doubao | ```python def is_good_integer(n): for digit in str(n): if int(digit) not in [0, 2, 4, 6, 8]: return False return True N = int(input()) count = 0 num = 0 while count < N: num += 1 if is_good_integer(num): count += 1 print(num) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE N = int(input()) n = N - 1 digits = [] while n > 0: digits.append(n % 5) n //= 5 if not digits: digits = [0] digits = digits[::-1] # Reverse the digits to get the correct order mapped_digits = [] for d in digits: if d == 0: mapped_digits.append('0') elif d == 1: mapped_digits.append('2') elif d == 2: mapped_digits.append('4') elif d == 3: mapped_digits.append('6') elif d == 4: mapped_digits.append('8') result = int(''.join(mapped_digits)) print(result) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| kimi | ```python import math def count_good_numbers(n): count = 0 for digit in range(5): count += n // 5 ** digit * 5 ** (digit + 1) * 4 ** (digit) n %= 5 ** digit return count def find_good_number(n): if n == 0: return 0 max_len = int(math.log10(n)) + 1 num = '' for i in range(max_len): base = 5 ** (max_len - i - 1) count = n // base + 1 if i == max_len - 1 else 1 num += str(2 * (count - 1)) n -= count * base return int(num) # YOUR CODE HERE N = int(input()) ans = find_good_number(count_good_numbers(N)) print(ans) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| minimax | ```python # YOUR CODE HERE def is_good_integer(n): return all(int(digit) % 2 == 0 for digit in str(n)) def find_nth_good_integer(N): count = 0 current = 0 while True: if is_good_integer(current): count += 1 if count == N: return current current += 1 # Read the input from stdin N = int(input()) # Solve the problem and write the answer to stdout print(find_nth_good_integer(N)) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| wenxinyiyan | ```python # YOUR CODE HERE def find_nth_good_integer(n): if n == 1: return 0 digits = [0, 2, 4, 6, 8] result = "" while n > 0: # Calculate the number of good integers with the current prefix count = len(digits) # For the single-digit case for i in range(1, len(result) + 1): count *= 5 # Each additional digit can be any of the 5 even digits # Find the index of the next digit digit_index = (n - 1) % len(digits) result = str(digits[digit_index]) + result # Update n to find the next digit n = (n - 1) // len(digits) + 1 # If the result starts with 0 and has more than one digit, remove the leading 0 if len(result) > 1 and result[0] == '0': result = result[1:] return int(result) # Read the input N = int(input()) # Find and print the N-th good integer print(find_nth_good_integer(N)) ``` **Note**: The provided solution assumes that the input value of `N` satisfies the given constraints. It efficiently finds the N-th smallest good integer by iteratively building the result string from the least significant digit to the most significant digit. The algorithm has a time complexity of O(log(N)) since it adds one digit to the result in each iteration, and the number of iterations is bounded by the number of digits in the final result. |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| zhipu | ```python def find_nth_good_integer(n): # Convert the given number to a base-5 number, since we have 5 even digits (0, 2, 4, 6, 8) base5_representation = [] while n > 0: base5_representation.append(n % 5) n //= 5 # Map the base-5 digits to the corresponding even digits even_digits = [0, 2, 4, 6, 8] good_integer = 0 for digit in base5_representation: good_integer = good_integer * 10 + even_digits[digit] return good_integer def main(): import sys input = sys.stdin.read n = int(input().strip()) # Find the N-th smallest good integer result = find_nth_good_integer(n - 1) # Subtract 1 because we start counting from 0 print(result) if __name__ == "__main__": main() ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |
| deepseek-v3 | ```python # YOUR CODE HERE def find_nth_good_integer(N): result = "" while N > 0: digit = (N - 1) % 5 result = str(digit * 2) + result N = (N - 1) // 5 return result # Read input N = int(input()) # Compute the N-th good integer answer = find_nth_good_integer(N) # Print the result print(answer) ``` |
[{"input": "8\n", "output": "24\n", "testtype": "stdin"}, {"input": "133\n", "output": "2024\n", "testtype": "stdin"}, {"input": "31415926535\n", "output": "2006628868244228\n", "testtype": "stdin"}] |