結果

問題 No.462 6日知らずのコンピュータ
ユーザー fal_rnd
提出日時 2016-12-13 22:57:17
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 2,446 ms
コンパイル使用メモリ 77,320 KB
実行使用メモリ 56,152 KB
最終ジャッジ日時 2024-11-30 01:43:06
合計ジャッジ時間 17,471 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

package src;

import java.math.BigInteger;
import java.util.*;
class B{
	static Scanner s = new Scanner(System.in);
	static final int mod=1000000007;
	public static void main(String[] args){
		int n=s.nextInt();
		BigInteger[] in = new BigInteger[s.nextInt()];
		for(int i=0;i<in.length;i++)
			in[i]=s.nextBigInteger();
		Arrays.sort(in);
		{
			BigInteger b = BigInteger.ZERO;
			for(BigInteger bb:in) {
				b=b.or(bb);
				if(b.xor(bb).getLowestSetBit()!=-1) {
					System.out.println(0);
					return;
				}
			}
		}
		{
			int r=1;
			int b=0;
			for(BigInteger bb:in) {
				r*=getFactorial(bb.bitCount()-b, mod);
				b=bb.bitCount();
			}
			r*=getFactorial(n-b,mod);
			System.out.println(r);
		}
	}
	static int getFactorial(long value,int mod) {
		if(value==0||value==1)
			return 1;
		if(value==2)
			return 2;
		return g(value,value-1,mod);
	}
	static int g(long v,long i,int m) {
		if(i==2)
			return (int) ((v*2)%m);
		return g(v*i,i-1,m);
	}
}
0