結果

問題 No.2344 (l+r)^2
ユーザー ytqm3
提出日時 2023-06-02 21:49:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 197,724 KB
最終ジャッジ日時 2025-02-13 18:01:56
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |   scanf("%d%d",&N,&M);
      |   ~~~~~^~~~~~~~~~~~~~
main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |   for(auto& v:A){ scanf("%lld",&v); }
      |                   ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using i64=long long;

i64 solve_sub(vector<i64> A,int M){
  while(A.size()>1){
    vector<i64> B(A.size()-1);
    for(int i=0;i<A.size()-1;++i){
      B[i]=(A[i]+A[i+1])*(A[i]+A[i+1])%(1ll<<M);
    }
    A=B;
  }
  return A[0];
}

void solve(){
  int N,M;
  scanf("%d%d",&N,&M);
  vector<i64> A(N);
  for(auto& v:A){ scanf("%lld",&v); }
  if(N>=60){
    vector<i64> B(60);
    for(int k=0;k<60;++k){
      for(int i=0;i<N-59;++i){
        B[k]^=A[i+k]%2*(((N-60)&i)==i?1:0);
      }
    }
    A=B;
  }
  printf("%d\n",int(solve_sub(A,M)));
}

int main(){
	int T;
	cin>>T;
	while(T--){
		solve();
	}
}
0