結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
![]() |
提出日時 | 2017-02-28 00:40:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,172 bytes |
コンパイル時間 | 2,850 ms |
コンパイル使用メモリ | 111,204 KB |
実行使用メモリ | 26,328 KB |
最終ジャッジ日時 | 2024-06-11 20:19:54 |
合計ジャッジ時間 | 7,148 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 16 RE * 42 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplicationSharp { class Program { static void Main(string[] args) { long mod = (long)1e9 + 7; string[] s = Console.ReadLine().Split(' '); int n = int.Parse(s[0]), k = int.Parse(s[1]); if (k == 0) { //答えはn! long ret = 1; for (int i = 2; i <= n; i++) ret = (ret * i) % mod; Console.WriteLine(ret); } else { s = Console.ReadLine().Split(' '); int[] a = new int[k]; for (int i = 0; i < k; i++) a[i] = int.Parse(s[i]); Array.Sort(a); long ret = 1; int cnt = 0; for (int i = 0; (1 << i) <= a[0]; i++) { if ((a[0]>>i)%2==1) cnt++; } for (int i = 2; i <= cnt; i++) ret = (ret * cnt) % mod; for(int i = 1; i < k; i++) { if ((a[i] & a[i - 1]) != a[i - 1]) { ret = 0; break; } int diff = a[i] ^ a[i - 1]; cnt = 0; for(int j = 0; j < n; j++) { if ((diff >> j) % 2 == 1) cnt++; } for (int j = 2; j <= cnt; j++) ret = (ret * j) % mod; } Console.WriteLine(ret); } } } }