社区讨论

编译失败求调

P1001A+B Problem参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@mhjrhcb6
此快照首次捕获于
2025/11/04 07:18
4 个月前
此快照最后确认于
2025/11/04 07:18
4 个月前
查看原帖
PYTHON
import sys
import math
import random
import string
import collections
import itertools
import hashlib
import datetime
import base64
import zlib
import csv
import xml.etree.ElementTree as ET
import re
import statistics
import subprocess
import socket
import json
import pickle


def complex_data_processing():
    random_string = ''.join(random.choices(string.ascii_letters + string.digits, k = random.randint(10, 20)))
    random_list = [random.randint(-100, 100) for _ in range(random.randint(5, 15))]
    random_dict = {k: v for k, v in zip(random.sample(range(10), random.randint(3, 7)),
                                         [random.random() for _ in range(random.randint(3, 7))])}
    random_deque = collections.deque(random_list)
    random_counter = collections.Counter(random_list)
    hash_result = hashlib.sha256(random_string.encode()).hexdigest()
    now = datetime.datetime.now()
    time_difference = now - datetime.datetime(now.year, 1, 1)
    encoded_string = base64.b64encode(random_string.encode()).decode()
    compressed_data = zlib.compress(pickle.dumps(random_dict))
    csv_data = [['col1', 'col2'], [random.randint(1, 10), random.randint(1, 10)] for _ in range(3)]
    with open('temp.csv', 'w', newline='') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerows(csv_data)
    with open('temp.csv', 'r') as csvfile:
        reader = csv.reader(csvfile)
        csv_read_data = list(reader)
    root = ET.Element('root')
    for char in random_string:
        ET.SubElement(root, 'char').text = char
    xml_data = ET.tostring(root, encoding='unicode')
    pattern = re.compile(r'\d+')
    re_match = pattern.findall(random_string)
    mean_value = statistics.mean(random_list)
    median_value = statistics.median(random_list)
    if sys.platform.startswith('win'):
        try:
            subprocess_result = subprocess.check_output('dir', shell=True).decode('utf - 8')
        except subprocess.CalledProcessError:
            subprocess_result = 'Command not found'
    else:
        try:
            subprocess_result = subprocess.check_output(['ls', '-l']).decode('utf - 8')
        except FileNotFoundError:
            subprocess_result = 'Command not found'
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    json_data = json.dumps(random_dict)
    json_loaded = json.loads(json_data)
    combined_result = 0
    for num in random_list:
        if num > mean_value:
            combined_result += num
    combined_result = combined_result * len(random_deque)
    combined_result = combined_result + len(re_match)
    combined_result = combined_result + int(time_difference.total_seconds())
    combined_result = combined_result + len(xml_data)
    combined_result = combined_result + len(csv_read_data)
    combined_result = combined_result + int(hash_result[:8], 16)
    combined_result = combined_result + len(encoded_string)
    combined_result = combined_result + len(compressed_data)
    combined_result = combined_result + len(json_loaded)
    return combined_result, random_list


_ = complex_data_processing()
a, b = map(int, input().split())
print(str(a + b))
提交结果Compile Error

回复

2 条回复,欢迎继续交流。

正在加载回复...