結果
| 問題 |
No.822 Bitwise AND
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2019-04-26 23:15:39 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,690 bytes |
| コンパイル時間 | 1,298 ms |
| コンパイル使用メモリ | 107,392 KB |
| 実行使用メモリ | 18,040 KB |
| 最終ジャッジ日時 | 2024-06-25 18:15:53 |
| 合計ジャッジ時間 | 2,476 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
long l = 0;
long r = 0;
long d = 1;
for(int i=0;i<32;i++){
if((N >> i) % 2 == 1){
d *= 2;
continue;
}
r += d;
l -= d;
d *= 2;
}
if(r - d <= K && r - d >= -K){
Console.WriteLine("INF");
return;
}
int Kmax = 300;
int Ofs = 2 * Kmax;
long[] dp = new long[4 * Kmax];
dp[0 + Ofs] = 1;
long v = 1;
for(int i=0;i<31;i++){
if((N >> i) % 2 == 1){
v *= 2;
continue;
}
var ndp = new long[4 * Kmax];
for(int j=0;j< 4 * Kmax;j++){
if(dp[j] == 0) continue;
ndp[j] += dp[j];
if(j + v < 4 * Kmax) ndp[j + v] += dp[j];
if(j - v >= 0 ) ndp[j - v] += dp[j];
}
dp = ndp;
v *= 2;
}
long ans = 0;
for(int i=0;i<=K;i++) ans += dp[i + Ofs];
Console.WriteLine(ans);
}
int N,K;
public Sol(){
var d = ria();
N = d[0]; K = d[1];
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
kuuso1