結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー inksamuraiinksamurai
提出日時 2021-07-30 21:20:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,578 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 119,200 KB
実行使用メモリ 77,432 KB
最終ジャッジ日時 2023-10-14 03:06:56
合計ジャッジ時間 6,893 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,744 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 42 ms
5,200 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 4 ms
4,368 KB
testcase_10 AC 3 ms
4,368 KB
testcase_11 AC 3 ms
4,372 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 332 ms
13,360 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
#include <assert.h>
#include <cstring>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++) 
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define vi vector <int> 
#define vec(...) vector<__VA_ARGS__>
#define _3laEQ3x ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;

const int mxn=400000;
using wtfpii = tuple<int,vi,int>;

int n,k;
vi pot;
map<wtfpii,int> mp;

int f(int i,vi a,int s){
	if(mp.find({i,a,s})!=mp.end()) return mp[{i,a,s}];
	if(i==n and s==0) return 1;
	int now=0;
	rep(j,9){
		if(a[j]>0){
			a[j]--;
			now += f(i+1,a,(s+(j+1)*pot[i])%k);
			a[j]++;
		}
	}
	return mp[{i,a,s}]=now;
}

int main(){
_3laEQ3x;
	cin>>n>>k;
	vi a(10);
	rep(i,9) cin>>a[i];
	pot.pb(1);
	drep(i,n-1){
		pot.pb((pot.back()*10)%k);
	}
	reverse(all(pot));
	cout<<f(0,a,0)<<"\n";

// 
	return 0;
}
0