結果

問題 No.40 多項式の割り算
ユーザー cielciel
提出日時 2014-11-16 20:27:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 873 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 8,984 KB
最終ジャッジ日時 2023-08-30 07:19:49
合計ジャッジ時間 14,632 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,868 KB
testcase_01 AC 16 ms
7,912 KB
testcase_02 AC 17 ms
7,912 KB
testcase_03 AC 17 ms
7,820 KB
testcase_04 AC 2,723 ms
8,876 KB
testcase_05 AC 4,454 ms
8,984 KB
testcase_06 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 checkio(b):
	'''
	b=[]
	for s in a:
		s=re.sub(r'-','Z',s)
		s=re.sub(r'x','0,1',s)
		b.append([int(_) for _ in process(s).split(',')])
	'''
	c=[]
	while len(b[1])<=len(b[0]):
		d=b[0][-1]//b[1][-1]
		c.append(d)
		b[0]=sub(b[0],[0]*(len(b[0])-len(b[1]))+[e*d for e in b[1]])
		assert b[0][-1]==0
		b[0].pop()
	while len(b[0])>1 and b[0][-1]==0: b[0].pop()
	print(len(b[0])-1)
	print(' '.join(str(e) for e in b[0]))

if __name__ == '__main__':
	import sys
	if sys.version_info[0]>=3: raw_input=input
	raw_input()
	checkio([[int(e) for e in raw_input().split()],[0,-1,0,1]])
0