結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
AreTrash
|
| 提出日時 | 2016-12-13 06:29:09 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,829 bytes |
| コンパイル時間 | 1,882 ms |
| コンパイル使用メモリ | 118,248 KB |
| 実行使用メモリ | 29,716 KB |
| 最終ジャッジ日時 | 2024-11-30 00:38:40 |
| 合計ジャッジ時間 | 5,849 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 WA * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Linq;
namespace No462{
public class Program{
public static void Main(string[] args){
var sr = new StreamReader();
//---------------------------------
var N = sr.Next<int>();
var K = sr.Next<int>();
var A = sr.Next<long>(K);
const long mod = 1000000007;
var mf = Ex.ModFac(100, mod);
var a = A
.Concat(new[]{0, Ex.ModPow(2, N, mod) - 1})
.Select(x => Convert.ToString(x, 2).PadLeft(N, '0'))
.OrderBy(x => x.Count(c => c == '1')).ToArray();
var res = 1L;
for(var i = 1; i < K + 2; i++){
for(var j = 0; j < N; j++) if(a[i - 1][j] == '1' && a[i][j] == '0') res = 0L;
res *= mf[a[i].Count(c => c == '1') - a[i - 1].Count(c => c == '1')];
res %= mod;
}
Console.WriteLine(res);
//---------------------------------
}
}
public class Ex{
public static long[] ModFac(long n, long mod){
var ret = new long[n];
ret[0] = 1;
for(var i = 1; i < n; i++) ret[i] = ret[i - 1] * i % mod;
return ret;
}
public static long ModPow(long x, long pow, long mod){
var ret = 1L;
for(var i = 0; i < pow; i++){
ret *= x;
ret %= mod;
}
return ret;
}
}
public class StreamReader{
private readonly char[] _c = {' '};
private int _index = -1;
private string[] _input = new string[0];
private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());
public T Next<T>(){
if(_index == _input.Length - 1){
_index = -1;
while(true){
string rl = _sr.ReadLine();
if(rl == null){
if(typeof(T).IsClass) return default(T);
return (T)typeof(T).GetField("MinValue").GetValue(null);
}
if(rl != ""){
_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
break;
}
}
}
return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
}
public T[] Next<T>(int x){
var ret = new T[x];
for(var i = 0; i < x; ++i) ret[i] = Next<T>();
return ret;
}
public T[][] Next<T>(int y, int x){
var ret = new T[y][];
for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
return ret;
}
}
}
AreTrash