diff --git a/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README.md b/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README.md index a831982b8ccd9..681e8876240f2 100644 --- a/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README.md +++ b/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README.md @@ -207,6 +207,24 @@ impl Solution { } ``` +#### C# + +```cs +public class Solution { + public int CountPermutations(int[] complexity) { + const int mod = (int) 1e9 + 7; + long ans = 1; + for (int i = 1; i < complexity.Length; ++i) { + if (complexity[i] <= complexity[0]) { + return 0; + } + ans = ans * i % mod; + } + return (int) ans; + } +} +``` + diff --git a/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README_EN.md b/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README_EN.md index ef76ed93f5892..c46c22e1d01d8 100644 --- a/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README_EN.md +++ b/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/README_EN.md @@ -203,6 +203,24 @@ impl Solution { } ``` +#### C# + +```cs +public class Solution { + public int CountPermutations(int[] complexity) { + const int mod = (int) 1e9 + 7; + long ans = 1; + for (int i = 1; i < complexity.Length; ++i) { + if (complexity[i] <= complexity[0]) { + return 0; + } + ans = ans * i % mod; + } + return (int) ans; + } +} +``` + diff --git a/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/Solution.cs b/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/Solution.cs new file mode 100644 index 0000000000000..c7a066af48bd9 --- /dev/null +++ b/solution/3500-3599/3577.Count the Number of Computer Unlocking Permutations/Solution.cs @@ -0,0 +1,13 @@ +public class Solution { + public int CountPermutations(int[] complexity) { + const int mod = (int) 1e9 + 7; + long ans = 1; + for (int i = 1; i < complexity.Length; ++i) { + if (complexity[i] <= complexity[0]) { + return 0; + } + ans = ans * i % mod; + } + return (int) ans; + } +}