結果

問題 No.462 6日知らずのコンピュータ
ユーザー mbanmban
提出日時 2016-12-22 13:30:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 2,258 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 103,612 KB
実行使用メモリ 24,076 KB
最終ジャッジ日時 2023-08-21 05:28:37
合計ジャッジ時間 10,335 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,864 KB
testcase_01 AC 64 ms
23,736 KB
testcase_02 AC 63 ms
19,800 KB
testcase_03 AC 62 ms
21,920 KB
testcase_04 AC 63 ms
21,904 KB
testcase_05 AC 63 ms
23,956 KB
testcase_06 AC 63 ms
23,892 KB
testcase_07 AC 62 ms
21,972 KB
testcase_08 AC 57 ms
23,632 KB
testcase_09 AC 62 ms
19,892 KB
testcase_10 AC 63 ms
21,900 KB
testcase_11 AC 63 ms
21,904 KB
testcase_12 AC 63 ms
21,832 KB
testcase_13 AC 62 ms
21,924 KB
testcase_14 AC 63 ms
21,920 KB
testcase_15 AC 61 ms
21,840 KB
testcase_16 AC 63 ms
21,976 KB
testcase_17 AC 62 ms
19,860 KB
testcase_18 AC 63 ms
19,876 KB
testcase_19 AC 63 ms
23,868 KB
testcase_20 AC 63 ms
21,888 KB
testcase_21 AC 62 ms
19,772 KB
testcase_22 AC 62 ms
21,832 KB
testcase_23 AC 64 ms
23,872 KB
testcase_24 AC 63 ms
21,904 KB
testcase_25 AC 64 ms
23,900 KB
testcase_26 AC 63 ms
22,032 KB
testcase_27 AC 63 ms
21,892 KB
testcase_28 AC 63 ms
23,960 KB
testcase_29 AC 63 ms
23,964 KB
testcase_30 AC 63 ms
21,788 KB
testcase_31 AC 63 ms
21,912 KB
testcase_32 AC 64 ms
21,932 KB
testcase_33 AC 65 ms
21,852 KB
testcase_34 AC 63 ms
22,016 KB
testcase_35 AC 64 ms
23,880 KB
testcase_36 AC 62 ms
21,764 KB
testcase_37 AC 62 ms
21,832 KB
testcase_38 AC 66 ms
22,020 KB
testcase_39 AC 63 ms
21,828 KB
testcase_40 AC 63 ms
21,908 KB
testcase_41 AC 63 ms
22,036 KB
testcase_42 AC 62 ms
21,836 KB
testcase_43 AC 63 ms
22,020 KB
testcase_44 AC 63 ms
21,924 KB
testcase_45 AC 62 ms
21,928 KB
testcase_46 AC 63 ms
21,824 KB
testcase_47 AC 63 ms
21,920 KB
testcase_48 AC 64 ms
21,992 KB
testcase_49 AC 63 ms
24,076 KB
testcase_50 AC 62 ms
19,828 KB
testcase_51 AC 63 ms
21,960 KB
testcase_52 AC 63 ms
21,948 KB
testcase_53 AC 63 ms
21,812 KB
testcase_54 AC 63 ms
21,920 KB
testcase_55 AC 63 ms
21,924 KB
testcase_56 AC 63 ms
21,832 KB
testcase_57 AC 64 ms
21,840 KB
testcase_58 AC 63 ms
21,932 KB
testcase_59 AC 62 ms
21,944 KB
testcase_60 AC 62 ms
21,928 KB
testcase_61 AC 63 ms
23,968 KB
testcase_62 AC 62 ms
21,940 KB
testcase_63 AC 63 ms
21,876 KB
testcase_64 AC 62 ms
21,912 KB
testcase_65 AC 63 ms
21,868 KB
testcase_66 AC 63 ms
21,864 KB
testcase_67 AC 63 ms
21,832 KB
testcase_68 AC 63 ms
22,024 KB
testcase_69 AC 63 ms
19,872 KB
testcase_70 AC 63 ms
19,828 KB
testcase_71 AC 63 ms
21,944 KB
testcase_72 AC 64 ms
23,836 KB
testcase_73 AC 64 ms
21,940 KB
testcase_74 AC 63 ms
23,964 KB
testcase_75 AC 62 ms
19,888 KB
testcase_76 AC 63 ms
22,016 KB
testcase_77 AC 63 ms
23,816 KB
testcase_78 AC 64 ms
23,880 KB
testcase_79 AC 57 ms
21,440 KB
testcase_80 AC 56 ms
21,692 KB
testcase_81 AC 56 ms
21,480 KB
testcase_82 AC 56 ms
21,496 KB
testcase_83 AC 56 ms
21,488 KB
testcase_84 AC 61 ms
21,936 KB
testcase_85 AC 62 ms
21,912 KB
testcase_86 AC 56 ms
21,592 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 = 1000000007;
    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;
            }
         //   Console.WriteLine(count(b, a[i]));
          result*=  count(b, a[i]);
            result %= MOD;
            b = a[i];
        }

        result *= count(b, MyPow(2, N)-1);
        Console.WriteLine(result % MOD);


    }

    static long count(long a,long b)
    {
        int cnt = 0;
        for(int i = 0; i < N; i++)
        {
            if (a % 2 <b %2)
            {
                cnt++;
            }
            a /= 2;
            b /= 2;
        }
       // Console.WriteLine(cnt);
        return kaijou(cnt);
    }
    static bool check(long a,long b)
    {
        
        for (int i = 0; i < N; i++)
        {
            if (a % 2> b % 2)
            {
               
                return false;
            }
            a /= 2;
            b /= 2;
        }
        //Console.WriteLine("a");
        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;
        }
        else
        {
            return n * kaijou(n - 1) % MOD;
        }
    }
}
0