結果

問題 No.1444 !Andd
ユーザー 👑 NachiaNachia
提出日時 2021-03-26 21:35:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 4,596 ms
コンパイル使用メモリ 257,512 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 07:37:25
合計ジャッジ時間 6,168 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 16 ms
4,376 KB
testcase_04 AC 12 ms
4,376 KB
testcase_05 AC 31 ms
4,380 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 28 ms
4,380 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 22 ms
4,384 KB
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 34 ms
4,380 KB
testcase_13 AC 48 ms
4,380 KB
testcase_14 AC 38 ms
4,376 KB
testcase_15 AC 45 ms
4,376 KB
testcase_16 AC 68 ms
4,376 KB
testcase_17 AC 68 ms
4,376 KB
testcase_18 AC 68 ms
4,384 KB
testcase_19 AC 68 ms
4,380 KB
testcase_20 AC 68 ms
4,380 KB
testcase_21 AC 68 ms
4,376 KB
testcase_22 AC 68 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
vector<int> A;

int dp[2][1024]={};
int dp2[2][1024]={};

int main(){
  scanf("%d",&N);
  rep(i,N){
    int a; scanf("%d",&a);
    A.push_back(a);
  }

  dp[0][1]=1;

  for(int a:A){
    rep(i,1024){
      if(i*a<1024) dp2[0][i*a]+=dp[0][i]; else dp2[1][(i*a)&1023]+=dp[0][i];
      dp2[1][(i*a)&1023]+=dp[1][i];
      dp2[0][i&a]+=dp[1][i]+dp[0][i];
    }
    if(a==0) rep(i,1024) dp2[1][i]=0;
    int ans=0;
    rep(i,1024){
      dp[0][i]=min(dp2[0][i],1); dp2[0][i]=0;
      dp[1][i]=dp2[1][i]; dp2[1][i]=0;
      ans+=dp[0][i]+dp[1][i];
    }
    printf("%d\n",ans);
  }
  return 0;
}
0