結果

問題 No.40 多項式の割り算
ユーザー cielciel
提出日時 2015-08-09 02:11:44
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 633 ms / 5,000 ms
コード長 856 bytes
コンパイル時間 1,213 ms
コンパイル使用メモリ 77,664 KB
実行使用メモリ 91,876 KB
最終ジャッジ日時 2023-09-25 07:26:10
合計ジャッジ時間 10,675 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
76,664 KB
testcase_01 AC 73 ms
76,148 KB
testcase_02 AC 75 ms
76,380 KB
testcase_03 AC 75 ms
76,372 KB
testcase_04 AC 259 ms
82,140 KB
testcase_05 AC 372 ms
84,468 KB
testcase_06 AC 569 ms
90,452 KB
testcase_07 AC 628 ms
91,720 KB
testcase_08 AC 88 ms
78,928 KB
testcase_09 AC 326 ms
84,048 KB
testcase_10 AC 527 ms
88,960 KB
testcase_11 AC 233 ms
81,568 KB
testcase_12 AC 145 ms
79,744 KB
testcase_13 AC 515 ms
88,320 KB
testcase_14 AC 257 ms
81,884 KB
testcase_15 AC 254 ms
82,000 KB
testcase_16 AC 519 ms
88,076 KB
testcase_17 AC 125 ms
79,484 KB
testcase_18 AC 481 ms
86,884 KB
testcase_19 AC 633 ms
91,876 KB
testcase_20 AC 202 ms
81,284 KB
testcase_21 AC 113 ms
79,432 KB
testcase_22 AC 106 ms
79,612 KB
testcase_23 AC 195 ms
81,220 KB
testcase_24 AC 370 ms
84,848 KB
testcase_25 AC 76 ms
76,136 KB
testcase_26 AC 76 ms
76,332 KB
testcase_27 AC 76 ms
76,112 KB
testcase_28 AC 77 ms
76,120 KB
testcase_29 AC 77 ms
76,272 KB
testcase_30 AC 77 ms
76,344 KB
testcase_31 AC 75 ms
76,508 KB
testcase_32 AC 76 ms
76,328 KB
testcase_33 AC 75 ms
76,272 KB
testcase_34 AC 74 ms
76,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python

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