示例#1
0
from cj_input import cj_inputs
import math

total, data = cj_inputs("A-small-attempt3.in")

def psd_attacker(data):
	answer_list = []
	for i in data:
		answer = 0
		val_M = int(i[0])
		val_N = int(i[1])
		if val_M == val_N:
			answer = math.factorial(val_N)
		else:
			diff = (val_N - val_M)
			multi_1 = math.factorial(val_M)
			answer = (multi_1 * val_M * val_N)/(diff+1)+(multi_1) * (pow(val_M,diff)-val_M) * val_N/ math.factorial(diff)

		answer = answer%(1000000007)

		answer_list.append(answer)

	return answer_list

output_idx = 1
for i in psd_attacker(data):
	print "Case #%d: %d"%(output_idx, i)
	output_idx += 1
示例#2
0
from cj_input import cj_inputs

total, data = cj_inputs("C-large.in")

def list_remove(raw_list, diff):
	for a in range(len(raw_list)-2):
		a = (a)%len(raw_list)
		b = (a+1)%len(raw_list)
		c = (a+2)%len(raw_list)
		if len(raw_list) > 2:
			if abs(int(raw_list[a]) - int(raw_list[b])) == int(diff):
				if abs(int(raw_list[b]) - int(raw_list[c])) == int(diff):
					raw_list.remove(raw_list[a])
					a = (a)%len(raw_list)
					raw_list.remove(raw_list[a])
					a = (a)%len(raw_list)
					raw_list.remove(raw_list[a])
					return True

def card_game(data):
	idx = 0
	answer = []
	for i in range(idx, len(data), 2):
		diff = data[i][1]
		raw_list = data[i+1]
		for tn in range(len(raw_list)):
			if list_remove(raw_list, diff):
				continue
			else:
				break
		answer.append(len(raw_list))
示例#3
0
from cj_input import cj_inputs
import math

total, data = cj_inputs("A-small-attempt3.in")


def psd_attacker(data):
    answer_list = []
    for i in data:
        answer = 0
        val_M = int(i[0])
        val_N = int(i[1])
        if val_M == val_N:
            answer = math.factorial(val_N)
        else:
            diff = (val_N - val_M)
            multi_1 = math.factorial(val_M)
            answer = (multi_1 * val_M * val_N) / (diff + 1) + (multi_1) * (
                pow(val_M, diff) - val_M) * val_N / math.factorial(diff)

        answer = answer % (1000000007)

        answer_list.append(answer)

    return answer_list


output_idx = 1
for i in psd_attacker(data):
    print "Case #%d: %d" % (output_idx, i)
    output_idx += 1
示例#4
0
from cj_input import cj_inputs
num, data = cj_inputs('test.in')

def check_mine(array, x, y):
	if array[x][y] == '*':
		return True
	else:
		return False

def get_ngb(array, x, y):
	

def mine_sweeper(data):
	result 
	for i in data:
		if len(i) == 1:
			num