結果

問題 No.2784 繰り上がりなし十進和
ユーザー shobonvipshobonvip
提出日時 2024-06-14 21:36:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,651 bytes
コンパイル時間 3,940 ms
コンパイル使用メモリ 245,228 KB
実行使用メモリ 55,096 KB
最終ジャッジ日時 2024-06-14 21:37:17
合計ジャッジ時間 41,379 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 974 ms
54,840 KB
testcase_01 AC 994 ms
54,840 KB
testcase_02 AC 1,021 ms
54,836 KB
testcase_03 AC 1,000 ms
54,840 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 967 ms
54,840 KB
testcase_10 AC 972 ms
54,840 KB
testcase_11 WA -
testcase_12 AC 972 ms
54,836 KB
testcase_13 WA -
testcase_14 AC 973 ms
54,836 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/convolution>
#include<atcoder/modint>
typedef atcoder::modint998244353 mint;
typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int op(int a, int b){
	int ret = 0;
	vector<int> c;
	rep(i,0,6){
		c.push_back((a+b) % 10);
		a /= 10;
		b /= 10;
	}
	rrep(i,0,6){
		ret = ret * 10 + c[i];
	}
	return ret;
}

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

	vector<vector<mint>> seisei(6, vector<mint>(1000000));
	rep(i,0,6){
		int x = a[i];
		seisei[i][x] = 1;
		while(true){
			x = op(x, a[i]);
			if (seisei[i][x].val() == 1) break;
			seisei[i][x] = 1;
		}
	}

	vector<mint> ans(1000000);
	ans[0] = 1;
	rep(i,0,6){
		ans = atcoder::convolution(ans, seisei[i]);
		vector<mint> nans(1000000);
		rep(i,0,(int)ans.size()){
			if (ans[i].val() > 0) {
				nans[i % 1000000] = 1;
			}
		}
		swap(ans, nans);
	}

	cout << sum(ans).val() << '\n';

}

0