結果

問題 No.1239 Multiplication -2
ユーザー 沙耶花沙耶花
提出日時 2020-09-25 22:41:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,064 bytes
コンパイル時間 2,538 ms
コンパイル使用メモリ 212,052 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-09-10 15:56:13
合計ジャッジ時間 4,381 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 29 ms
4,600 KB
testcase_22 AC 29 ms
4,492 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 18 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000
mint ans = 0;

void go(vector<int> a){
	int now = 1;
	
	rep(i,a.size()-1){
		now *= a[i];
		if(now==-2){
			ans += mint(2).pow(i+1).inv();
		}
	}
}

void Go(vector<int> a){
	
	map<int,mint> mp;
	mp[1] = mint(2).inv();
	int t = 1;
	rep(i,a.size()){
		for(auto &a:mp){
			a.second /= 2;
		}
		t *= a[i];
		ans += mp[-2/t];
		mp[t] += mint(2).inv();
	}
	
}

int main(){

	int N;
	cin>>N;
	
	vector<int> a(N);
	rep(i,N){
		cin>>a[i];
	}

	go(a);

	reverse(a.begin(),a.end());
	go(a);
	
	int t = 1;
	rep(i,N){
		t *= a[i];
	}
	if(t==-2){
		ans += mint(2).pow(N-1).inv();
	}
	
	if(N>=3){
		/*
		a.erase(a.begin());
		a.pop_back();
		
		rep(i,a.size()){
			if(a[i]==0)continue;
			vector<int> T;
			while(i!=a.size()&&a[i]!=0){
				T.push_back(a[i]);
				i++;
			}
			if(T.size()>0){
				Go(T);
			}
		}
		*/
		
	}
	
	cout<<ans.val()<<endl;

	return 0;
}
0