結果

問題 No.462 6日知らずのコンピュータ
ユーザー kuuso1kuuso1
提出日時 2016-12-13 01:16:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 5,163 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 117,456 KB
実行使用メモリ 25,980 KB
最終ジャッジ日時 2024-11-29 23:57:40
合計ジャッジ時間 5,443 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,772 KB
testcase_01 AC 27 ms
25,704 KB
testcase_02 AC 27 ms
25,684 KB
testcase_03 AC 27 ms
23,856 KB
testcase_04 AC 26 ms
21,556 KB
testcase_05 AC 26 ms
23,852 KB
testcase_06 AC 27 ms
23,724 KB
testcase_07 AC 26 ms
23,728 KB
testcase_08 AC 25 ms
23,388 KB
testcase_09 AC 26 ms
23,600 KB
testcase_10 AC 26 ms
25,564 KB
testcase_11 AC 27 ms
23,932 KB
testcase_12 AC 26 ms
23,640 KB
testcase_13 AC 27 ms
23,776 KB
testcase_14 AC 27 ms
23,644 KB
testcase_15 AC 25 ms
23,520 KB
testcase_16 AC 27 ms
23,600 KB
testcase_17 AC 27 ms
23,768 KB
testcase_18 AC 26 ms
23,796 KB
testcase_19 AC 27 ms
23,644 KB
testcase_20 AC 27 ms
23,780 KB
testcase_21 AC 27 ms
23,772 KB
testcase_22 AC 27 ms
23,640 KB
testcase_23 AC 27 ms
25,824 KB
testcase_24 AC 27 ms
25,940 KB
testcase_25 AC 27 ms
25,816 KB
testcase_26 AC 27 ms
23,768 KB
testcase_27 AC 26 ms
23,600 KB
testcase_28 AC 27 ms
23,644 KB
testcase_29 AC 27 ms
23,668 KB
testcase_30 AC 26 ms
21,560 KB
testcase_31 AC 26 ms
23,772 KB
testcase_32 AC 27 ms
23,768 KB
testcase_33 AC 27 ms
23,780 KB
testcase_34 AC 26 ms
23,644 KB
testcase_35 AC 27 ms
23,516 KB
testcase_36 AC 26 ms
23,640 KB
testcase_37 AC 27 ms
21,816 KB
testcase_38 AC 27 ms
23,660 KB
testcase_39 AC 26 ms
21,692 KB
testcase_40 AC 27 ms
23,772 KB
testcase_41 AC 27 ms
23,644 KB
testcase_42 AC 28 ms
25,932 KB
testcase_43 AC 27 ms
25,804 KB
testcase_44 AC 27 ms
23,772 KB
testcase_45 AC 27 ms
23,768 KB
testcase_46 AC 27 ms
25,816 KB
testcase_47 AC 28 ms
23,664 KB
testcase_48 AC 27 ms
23,792 KB
testcase_49 AC 27 ms
23,512 KB
testcase_50 AC 27 ms
23,724 KB
testcase_51 AC 27 ms
25,948 KB
testcase_52 AC 27 ms
23,860 KB
testcase_53 AC 27 ms
23,644 KB
testcase_54 AC 26 ms
23,644 KB
testcase_55 AC 26 ms
23,772 KB
testcase_56 AC 26 ms
23,644 KB
testcase_57 AC 27 ms
23,724 KB
testcase_58 AC 27 ms
23,772 KB
testcase_59 AC 27 ms
25,980 KB
testcase_60 AC 27 ms
25,824 KB
testcase_61 AC 27 ms
23,532 KB
testcase_62 AC 25 ms
23,472 KB
testcase_63 AC 27 ms
23,640 KB
testcase_64 AC 26 ms
21,560 KB
testcase_65 AC 27 ms
23,896 KB
testcase_66 AC 27 ms
25,824 KB
testcase_67 AC 27 ms
23,856 KB
testcase_68 AC 27 ms
23,764 KB
testcase_69 AC 27 ms
25,956 KB
testcase_70 AC 27 ms
23,772 KB
testcase_71 AC 27 ms
25,692 KB
testcase_72 AC 26 ms
21,556 KB
testcase_73 AC 27 ms
25,832 KB
testcase_74 AC 26 ms
23,520 KB
testcase_75 AC 27 ms
25,824 KB
testcase_76 AC 26 ms
23,776 KB
testcase_77 AC 27 ms
23,928 KB
testcase_78 AC 27 ms
25,812 KB
testcase_79 AC 25 ms
23,384 KB
testcase_80 AC 25 ms
25,632 KB
testcase_81 AC 25 ms
25,424 KB
testcase_82 AC 24 ms
23,608 KB
testcase_83 AC 25 ms
23,512 KB
testcase_84 AC 26 ms
23,772 KB
testcase_85 AC 26 ms
25,816 KB
testcase_86 AC 24 ms
23,732 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long mod = (long)1e9 + 7;
		
		long[] Fact = new long[N+1];
		Fact[0] = 1;
		for(int i=1;i<=N;i++){
			Fact[i] = Fact[i-1] * i;
			Fact[i] %= mod;
		}
		
		if(K==0){
			Console.WriteLine(Fact[N]);
			return;
		}
		Array.Sort(A);
		int[] bc = new int[N];
		int tot = N;
		long ans = 1;
		for(int i=0;i<K;i++){
			long inc = A[i];
			if(i>0) inc -= A[i-1];
			int cnt = 0;
			for(int j=0;j<N;j++){
				if(((inc >> j)&1) == 1){ bc[j]++; cnt++;}
				if(bc[j]>1){
					Console.WriteLine(0);
					return;
				}
			}
			ans *= Fact[cnt];
			ans %= mod;
			tot -= cnt;
		}
		
		ans *= Fact[tot];
		ans %= mod;
		Console.WriteLine(ans);
		
		
		
		
		
	}
	int N,K;
	long[] A;
	public Sol(){
		using(var r = new FastIn()){
			N = r.ReadInt();
			K = r.ReadInt();
			if(K>0){
				A = new long[K];
				for(int i=0;i<K;i++) A[i] = r.ReadLong();
			}
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class FastIn:IDisposable {
	int Size;
	byte[] Mem;
	int ptr;
	int rsize;
	bool unfinished;
	Stream stdin;
	void Init(int n) {
		Size = n;
		Mem = new byte[Size];
		rsize=(stdin=Console.OpenStandardInput()).Read(Mem, 0, Size);
		ptr = 0;
		unfinished=(rsize == Size);
	}
	void Next() {
		if (unfinished == false) return;
		rsize=stdin.Read(Mem, 0, Size);
		ptr = 0;
		unfinished = (rsize == Size);
	}
	
	~FastIn(){
		stdin.Dispose();
	}
	void IDisposable.Dispose(){
		stdin.Dispose();
	}
	public void Dispose(){
		stdin.Dispose();
	}
	
	public FastIn() {
		Init(100000);
	}
	public FastIn(int n) {
		Init(n);
	}
	public int ReadInt() {
		int ret = 0;
		int sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++; continue;
			}
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public uint ReadUint() {
		uint ret = 0;
		uint sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	public long ReadLong() {
		long ret = 0;
		long sig = 1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++; continue;
			}
			ret = ret * 10 + Mem[ptr++] - '0';
			if (ptr == Size) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')  ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}
	
	public double ReadDouble() {
		double ret = 0;
		double sig = 1;
		bool dot = false;
		double keta = 0.1;
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r' ) {
			if(ret==0 && Mem[ptr] == '-'){
				sig *= -1; ptr++;
				if (ptr == Size) Next();
				continue;
			}
			if(Mem[ptr] == '.'){
				dot = true;
				ptr++;
				if (ptr == Size) Next();
				continue;
			}
			if(!dot){
				ret = ret * 10 + Mem[ptr++] - '0';
				if (ptr == Size) Next();
			}else{
				ret = ret + (Mem[ptr++] - '0')*keta;
				keta /= 10.0;
				if (ptr == Size) Next();
			}
		}
		while (ptr < rsize && (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size) Next();
		}
		return ret*sig;
	}

	public String ReadStr() {
		//2byte文字はNG
		StringBuilder sb = new StringBuilder();
		while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
			sb.Append((char)Mem[ptr++]);
			if (ptr == Size && unfinished) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r') ) {
			ptr++;
			if (ptr == Size && unfinished) Next();
		}
		return sb.ToString();
	}
	public String ReadLine() {
		//極力使わない(split/parseするくらいなら上をつかう)
		StringBuilder sb = new StringBuilder();
		while (ptr < rsize && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
			sb.Append((char)Mem[ptr++]);
			if (ptr == Size && unfinished) Next();
		}
		while (ptr < rsize &&  (Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
			ptr++;
			if (ptr == Size && unfinished) Next();
		}
		return sb.ToString();
	}
}
0