結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
![]() |
提出日時 | 2017-02-28 15:47:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,269 bytes |
コンパイル時間 | 4,388 ms |
コンパイル使用メモリ | 108,148 KB |
実行使用メモリ | 28,524 KB |
最終ジャッジ日時 | 2024-06-11 23:32:04 |
合計ジャッジ時間 | 8,299 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 6 WA * 78 |
コンパイルメッセージ
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) { ulong mod = (ulong)1e9 + 7; string[] s = Console.ReadLine().Split(' '); int n = int.Parse(s[0]), k = int.Parse(s[1]); if (k == 0) { //答えはn! ulong ret = 1; for (int i = 2; i <= n; i++) ret = (ret * (ulong)i) % mod; Console.WriteLine(ret); } else { s = Console.ReadLine().Split(' '); int count = 0; foreach(String str in s) { Console.WriteLine("{0}\t{1}", count++, str); } ulong[] a = new ulong[k+2]; for (int i = 0; i < k; i++) { Console.WriteLine(i); a[i + 1] = ulong.Parse(s[i]); } a[0] = 0; a[k + 1] = (1UL << n) - 1; Array.Sort(a); ulong ret = 1; //a[0]=0は確定->ret=1 for(int i = 1; i < k+2; i++) { if ((a[i] & a[i - 1]) != a[i - 1]) { ret = 0; break; } ulong diff = a[i] ^ a[i - 1]; ulong cnt = 0; for(int j = 0; j < n; j++) { if ((diff >> j) % 2L == 1L) cnt++; } for (ulong j = 2; j <= cnt; j++) ret = (ret * j) % mod; } Console.WriteLine(ret); } } } }