結果

問題 No.986 Present
ユーザー 37zigen37zigen
提出日時 2020-04-22 01:06:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 3,246 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 80,520 KB
実行使用メモリ 61,904 KB
最終ジャッジ日時 2024-04-17 22:56:40
合計ジャッジ時間 8,134 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
59,176 KB
testcase_01 AC 117 ms
59,076 KB
testcase_02 AC 120 ms
59,316 KB
testcase_03 AC 168 ms
61,592 KB
testcase_04 AC 129 ms
59,132 KB
testcase_05 AC 168 ms
61,760 KB
testcase_06 AC 147 ms
61,336 KB
testcase_07 AC 126 ms
59,040 KB
testcase_08 AC 135 ms
61,304 KB
testcase_09 AC 163 ms
61,636 KB
testcase_10 AC 117 ms
59,268 KB
testcase_11 AC 157 ms
61,660 KB
testcase_12 AC 150 ms
61,664 KB
testcase_13 AC 123 ms
59,256 KB
testcase_14 AC 117 ms
59,188 KB
testcase_15 AC 186 ms
61,620 KB
testcase_16 AC 132 ms
59,264 KB
testcase_17 AC 173 ms
61,628 KB
testcase_18 AC 148 ms
61,688 KB
testcase_19 AC 128 ms
61,504 KB
testcase_20 AC 124 ms
59,284 KB
testcase_21 AC 187 ms
61,436 KB
testcase_22 AC 185 ms
61,780 KB
testcase_23 AC 142 ms
61,664 KB
testcase_24 AC 194 ms
61,904 KB
testcase_25 AC 131 ms
61,268 KB
testcase_26 AC 190 ms
61,708 KB
testcase_27 AC 176 ms
61,564 KB
testcase_28 AC 119 ms
59,352 KB
testcase_29 AC 114 ms
59,236 KB
testcase_30 AC 119 ms
59,196 KB
testcase_31 AC 120 ms
59,256 KB
testcase_32 AC 118 ms
59,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.NoSuchElementException;


public class Main {
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	final long MOD=998244353;
	long[] p2=new long[(int)1e6];
	{
		p2[0]=1;
		for (int i=1;i<p2.length;++i) p2[i]=2*p2[i-1]%MOD;
	}
	
	long euclid(long a,long b,long p,long q) {
		return q==0?a:euclid(b,(a-p/q*b)%MOD,q,p%q);
	}
	
	long inv(long a) {
		long v=euclid(1,0,a,MOD);
		return v<0?v+MOD:v;
	}
	
	long mul(long...a) {
		long ret=1;
		for (long v:a) ret=ret*((v%MOD+MOD)%MOD)%MOD;
		return ret;
	}
	
	long comb(int n,int k) {
		long ret=1;
		for (long i=n;i>=n-k+1;--i) ret=ret*i%MOD;
		for (long i=1;i<=k;++i) ret=ret*inv(i)%MOD;
		return ret;
	}
	
	long pow(long a,long n) {
		return n==0?1:(pow(a*a%MOD,n/2)*(n%2==1?a:1))%MOD;
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();// size N
		int M=sc.nextInt();// [0,2^M)
		long v0=p2[N],v1=1,v2=1;
		for (int i=0;i<N;++i) {
			v1=mul(v1,p2[M]-p2[i],inv(i+1));
		}
		for (int i=0;i<N;++i) {
			v2=mul(p2[N]-p2[i],v2,inv(i+1));
		}
		System.out.println(v0+" "+v1+" "+mul(v1,inv(v2)));
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}




class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
    	return (int)nextLong();
    }
}
0