結果

問題 No.265 数学のテスト
ユーザー cielciel
提出日時 2015-08-09 02:33:46
言語 PyPy2
(7.3.15)
結果
RE  
実行時間 -
コード長 1,798 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 77,600 KB
実行使用メモリ 202,200 KB
最終ジャッジ日時 2023-09-25 07:26:34
合計ジャッジ時間 5,069 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
#Use PyPy to AC.

import re

def add(a,b):
	m=max(len(a),len(b))
	return [(0 if len(a)<=i else a[i])+(0 if len(b)<=i else b[i]) for i in range(m)]

def sub(a,b):
	return add(a,[-1*e for e in b])

def mul(a,b):
	r=[]
	for i in range(len(b)):
		r=add(r,[0]*i+[b[i]*e for e in a])
	return r

def dif(a):
	if len(a)<=1: return [0]
	return [i*a[i] for i in range(1,len(a))]

def process(s):
	try:
		while True:
			bidx=s.index('(')
			count=1
			eidx=bidx+1
			while count>0:
				if s[eidx]=='(': count+=1
				if s[eidx]==')': count-=1
				eidx+=1
			s=s[:bidx]+process(s[bidx+1:eidx-1])+s[eidx:]
	except ValueError:
		pass
	try:
		while True:
			bidx=s.index('d')
			count=1
			eidx=bidx+2
			while count>0:
				if s[eidx]=='{': count+=1
				if s[eidx]=='}': count-=1
				eidx+=1
			s=s[:bidx]+','.join(str(f) for f in dif([int(e) for e in process(s[bidx+2:eidx-1]).split(',')]))+s[eidx:]
	except ValueError:
		pass
	while True:
		m=re.match(r'(.*?)([0-9,-]+)([*])([0-9,-]+)(.*)',s)
		if not m: break
		s=m.group(1)+','.join(str(f) for f in mul([int(e) for e in m.group(2).split(',')],[int(e) for e in m.group(4).split(',')]))+m.group(5)
	while True:
		m=re.match(r'(.*?)([0-9,-]+)([+Z])([0-9,-]+)(.*)',s)
		if not m: break
		if m.group(3)=='+':
			s=m.group(1)+','.join(str(f) for f in add([int(e) for e in m.group(2).split(',')],[int(e) for e in m.group(4).split(',')]))+m.group(5)
		else:
			s=m.group(1)+','.join(str(f) for f in sub([int(e) for e in m.group(2).split(',')],[int(e) for e in m.group(4).split(',')]))+m.group(5)
	return s

if __name__ == '__main__':
	import sys
	if sys.version_info[0]>=3: raw_input=input
	raw_input()
	d=int(raw_input())
	s=raw_input().rstrip().replace('-','Z').replace('x','0,1')
	r=process(s).split(',')
	r+=['0']*(d+1-len(r))
	print(' '.join(r))
0