当前位置 : 主页 > 网页制作 > HTTP/TCP >

F. Special Matrices

来源:互联网 收集:自由互联 发布时间:2021-06-16
http://codeforces.com/contest/489/problem/F http://blog.lightning34.cn/?p=107 1 public static void main(String[] args) { 2 n = io.nextInt(); 3 m = io.nextInt(); 4 mod = io.nextInt(); 5 6 String s; 7 for ( int i = 0; i m; i++ ) { 8 s = io.ne

 

http://codeforces.com/contest/489/problem/F

 

http://blog.lightning34.cn/?p=107

 

 1     public static void main(String[] args) {
 2         n = io.nextInt();
 3         m = io.nextInt();
 4         mod = io.nextInt();
 5 
 6         String s;
 7         for (int i = 0; i < m; i++) {
 8             s = io.nextLine();
 9             while (s.length() == 0) s = io.nextLine();
10             for (int j = 0; j < s.length(); j++) y[j] += s.charAt(j) - ‘0‘;
11         }
12 
13         for (int i = 0; i < n; i++) sum[y[i]]++;
14         dp[sum[0]][sum[1]] = 1;
15 
16         //0的个数
17         for (int i = n; i >= 0; i--) {
18             //1的个数
19             for (int j = n; j >= 0; j--) {
20                 if (j >= 2) dp[i][j - 2] = (dp[i][j - 2] + dp[i][j] * j * (j - 1) / 2) % mod;
21                 if (i >= 1) dp[i - 1][j] = (dp[i - 1][j] + dp[i][j] * i * j) % mod;
22                 if (i >= 2) dp[i - 2][j + 2] = (dp[i - 2][j + 2] + dp[i][j] * i * (i - 1) / 2) % mod;
23             }
24         }
25         System.out.println(dp[0][0]);
26     }
上一篇:GET POST 区分
下一篇:数据仓库
网友评论