結果

問題 No.1181 Product Sum for All Subsets
ユーザー kakel-san
提出日時 2025-06-05 23:12:08
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,048 bytes
コンパイル時間 24,638 ms
コンパイル使用メモリ 170,552 KB
実行使用メモリ 187,160 KB
最終ジャッジ日時 2025-06-05 23:12:36
合計ジャッジ時間 10,747 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (128 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var mod = 1_000_000_007;
        var half = 500000004;
        var mul1 = (k % mod * k % mod + 3 * (k % mod) % mod) * half % mod;
        var mul2 = (k % mod * k % mod + k % mod) * half % mod;
        WriteLine((Exp(mul1, n, mod) - Exp(mul2, n, mod) + mod) % mod);
    }
    static long Exp(long n, long p, int mod)
    {
        long _n = n % mod;
        var _p = p;
        var result = 1L;
        if ((_p & 1) == 1) result *= _n;
        while (_p > 0)
        {
            _n = _n * _n % mod;
            _p >>= 1;
            if ((_p & 1) == 1) result = result * _n % mod;
        }
        return result;
    }
}
0