結果

問題 No.462 6日知らずのコンピュータ
ユーザー mbanmban
提出日時 2016-12-22 13:08:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,070 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 116,644 KB
実行使用メモリ 29,608 KB
最終ジャッジ日時 2024-05-08 10:59:28
合計ジャッジ時間 5,949 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
25,256 KB
testcase_01 AC 31 ms
25,492 KB
testcase_02 AC 32 ms
25,364 KB
testcase_03 AC 32 ms
25,232 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 32 ms
25,524 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 33 ms
25,260 KB
testcase_24 AC 31 ms
25,232 KB
testcase_25 AC 32 ms
25,360 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 32 ms
27,436 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 32 ms
25,392 KB
testcase_34 WA -
testcase_35 AC 32 ms
25,392 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 34 ms
27,424 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 32 ms
25,392 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 31 ms
25,132 KB
testcase_45 AC 31 ms
27,168 KB
testcase_46 WA -
testcase_47 AC 32 ms
25,136 KB
testcase_48 WA -
testcase_49 AC 31 ms
25,488 KB
testcase_50 AC 31 ms
25,492 KB
testcase_51 AC 31 ms
25,488 KB
testcase_52 AC 32 ms
27,560 KB
testcase_53 AC 32 ms
25,360 KB
testcase_54 AC 31 ms
25,492 KB
testcase_55 AC 31 ms
25,236 KB
testcase_56 AC 32 ms
27,296 KB
testcase_57 AC 32 ms
25,356 KB
testcase_58 AC 33 ms
27,180 KB
testcase_59 AC 32 ms
27,528 KB
testcase_60 AC 33 ms
27,400 KB
testcase_61 AC 32 ms
27,308 KB
testcase_62 WA -
testcase_63 AC 32 ms
27,180 KB
testcase_64 AC 31 ms
25,104 KB
testcase_65 AC 31 ms
27,428 KB
testcase_66 AC 31 ms
25,524 KB
testcase_67 AC 33 ms
23,600 KB
testcase_68 AC 32 ms
27,428 KB
testcase_69 AC 31 ms
25,392 KB
testcase_70 AC 31 ms
25,260 KB
testcase_71 AC 32 ms
25,356 KB
testcase_72 AC 31 ms
25,108 KB
testcase_73 AC 32 ms
25,388 KB
testcase_74 AC 33 ms
25,616 KB
testcase_75 AC 33 ms
25,108 KB
testcase_76 AC 32 ms
25,136 KB
testcase_77 AC 33 ms
25,108 KB
testcase_78 AC 32 ms
25,108 KB
testcase_79 AC 27 ms
24,588 KB
testcase_80 WA -
testcase_81 AC 27 ms
24,724 KB
testcase_82 WA -
testcase_83 WA -
testcase_84 AC 31 ms
25,620 KB
testcase_85 AC 32 ms
27,272 KB
testcase_86 AC 27 ms
24,724 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.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(long n)
    {
        if (n == 0)
        {
            return 1;
        }
        return n * kaijou(n - 1)%MOD;
    }
}
0