結果
問題 | No.986 Present |
ユーザー | 37zigen |
提出日時 | 2020-04-22 01:06:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 225 ms / 2,000 ms |
コード長 | 3,246 bytes |
コンパイル時間 | 2,635 ms |
コンパイル使用メモリ | 80,332 KB |
実行使用メモリ | 51,664 KB |
最終ジャッジ日時 | 2024-10-09 16:39:02 |
合計ジャッジ時間 | 8,953 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 129 ms
47,540 KB |
testcase_01 | AC | 132 ms
47,680 KB |
testcase_02 | AC | 121 ms
47,828 KB |
testcase_03 | AC | 178 ms
51,464 KB |
testcase_04 | AC | 130 ms
48,084 KB |
testcase_05 | AC | 175 ms
51,364 KB |
testcase_06 | AC | 157 ms
50,904 KB |
testcase_07 | AC | 131 ms
47,852 KB |
testcase_08 | AC | 150 ms
50,128 KB |
testcase_09 | AC | 184 ms
51,464 KB |
testcase_10 | AC | 124 ms
47,692 KB |
testcase_11 | AC | 168 ms
51,664 KB |
testcase_12 | AC | 169 ms
51,540 KB |
testcase_13 | AC | 129 ms
47,580 KB |
testcase_14 | AC | 135 ms
48,412 KB |
testcase_15 | AC | 212 ms
51,440 KB |
testcase_16 | AC | 131 ms
48,432 KB |
testcase_17 | AC | 192 ms
51,644 KB |
testcase_18 | AC | 169 ms
51,552 KB |
testcase_19 | AC | 148 ms
50,236 KB |
testcase_20 | AC | 127 ms
47,748 KB |
testcase_21 | AC | 209 ms
51,308 KB |
testcase_22 | AC | 197 ms
51,496 KB |
testcase_23 | AC | 161 ms
51,548 KB |
testcase_24 | AC | 225 ms
51,548 KB |
testcase_25 | AC | 145 ms
49,616 KB |
testcase_26 | AC | 223 ms
51,492 KB |
testcase_27 | AC | 197 ms
51,544 KB |
testcase_28 | AC | 122 ms
47,788 KB |
testcase_29 | AC | 121 ms
47,672 KB |
testcase_30 | AC | 123 ms
47,696 KB |
testcase_31 | AC | 121 ms
47,648 KB |
testcase_32 | AC | 121 ms
47,808 KB |
ソースコード
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(); } }