Submission #4024476


Source Code Expand

// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Wed Jan 16 16:34:18 2019
//
package main

import "fmt"

const mod = 1e9 + 7

var dp = map[int]int{}

func fact(n int) int {
	if v, ok := dp[n]; ok {
		return v
	}
	dp[n] = (n * fact(n-1)) % mod
	return dp[n]
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	dp[0] = 1
	if N == M {
		fmt.Println((2 * (fact(N) * fact(M)) % mod) % mod)
	} else if N-1 == M || N == M-1 {
		fmt.Println((fact(N) * fact(M)) % mod)
	} else {
		fmt.Println(0)
	}
}

Submission Info

Submission Time
Task C - Reconciled?
User mohei
Language Go (1.6)
Score 300
Code Size 559 Byte
Status AC
Exec Time 58 ms
Memory 19072 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 16
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt AC 1 ms 512 KB
02.txt AC 53 ms 16128 KB
03.txt AC 1 ms 512 KB
04.txt AC 58 ms 16128 KB
05.txt AC 54 ms 19072 KB
06.txt AC 1 ms 512 KB
07.txt AC 1 ms 512 KB
08.txt AC 1 ms 512 KB
09.txt AC 53 ms 19072 KB
10.txt AC 57 ms 19072 KB
11.txt AC 1 ms 512 KB
12.txt AC 1 ms 512 KB
s1.txt AC 1 ms 512 KB
s2.txt AC 1 ms 512 KB
s3.txt AC 1 ms 512 KB
s4.txt AC 58 ms 16128 KB