結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
![]() |
提出日時 | 2016-12-22 13:06:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,069 bytes |
コンパイル時間 | 1,146 ms |
コンパイル使用メモリ | 112,268 KB |
実行使用メモリ | 29,336 KB |
最終ジャッジ日時 | 2024-12-14 14:20:57 |
合計ジャッジ時間 | 5,737 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 47 WA * 37 |
コンパイルメッセージ
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; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static int N, K; const long MOD = (long)1e7; static void Main() { string[] s = Console.ReadLine().Split(' '); N = int.Parse(s[0]); K = int.Parse(s[1]); if (K == 0) { Console.WriteLine(kaijou(N)); return; } long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); Array.Sort(a); long b = 0; long result = 1; for(int i = 0; i < K; i++) { if (!check(b, a[i])) { Console.WriteLine(0); return; } result*= count(b, a[i]); b = a[i]; } result *= count(b, MyPow(2, N)); Console.WriteLine(result % MOD); } static long count(long a,long b) { int cnt = 0; for(int i = 0; i < N; i++) { if (a % 2 == 0 && b %2== 1) { cnt++; } a /= 2; b /= 2; } return kaijou(cnt); } static bool check(long a,long b) { for (int i = 0; i < N; i++) { if (a % 2 == 1 && b % 2 == 0) { return false; } a /= 2; b /= 2; } return true; } static long MyPow(long a,long b) { long result = 1; while (b > 0) { if (b % 2 == 0) { a *= a; // a %= MOD; b /= 2; } else { result *= a; // result %= MOD; b--; } } return result; } static long kaijou(int n) { if (n == 0) { return 1; } return n * kaijou(n - 1)%MOD; } }