結果

問題 No.1629 Sorting Integers (SUM of M)
ユーザー 風月風月
提出日時 2021-07-30 21:36:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 2,362 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 198,312 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 03:47:01
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 5 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 6 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 5 ms
4,348 KB
testcase_11 AC 4 ms
4,352 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 4 ms
4,352 KB
testcase_15 AC 5 ms
4,352 KB
testcase_16 AC 5 ms
4,352 KB
testcase_17 AC 9 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_map>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define Ios std::ios::sync_with_stdio(false),std::cin.tie(0)
#define ull unsigned long long
#define ll long long
#define db double
#define PII std::pair<int,int>
#define PLI std::pair<long long , int>
template<class T> void chkmax(T& a, T b) { a > b ? (a = a) : (a = b); }
template<class T> void chkmin(T& a, T b) { a > b ? (a = b) : (a = a); }
template<class T> T min(T a, T b) { return a > b ? b : a; }
template<class T> T max(T a, T b) { return a < b ? b : a; }
template<class T> T abs(T a) { return a < 0 ? -a : a; }
//using namespace std;
/*
	1.注意边界情况
	2.优先考虑时间复杂度
!!! 3.求最大值时,答案应至多初始化为INT_MIN;求最小值时,答案应至少初始化为INT_MAX
	4.遇事不决先暴力
	5.代码要写简洁
	6.计数题要开long long
*/
//快速IO
template<class T>
inline bool rd(T& ret) {
	char c; int sgn;
	if (c = getchar(), c == EOF) return 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar();
	sgn = (c == '-') ? -1 : 1;
	ret = (c == '-') ? 0 : (c - '0');
	while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	ret *= sgn;
	return true;
}
template<class T>
inline void print(T x) {
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
	return;
}
using std::vector;
using std::queue;
using std::string;
using std::map;
using std::unordered_map;
using std::priority_queue;
using std::cout;
using std::cin;

int mod = 1e9 + 7;

int quickPow(int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1) res = 1ll * res * a % mod;
		n >>= 1;
		a = 1ll * a * a % mod;
	}
	return res;
}

int n, ct, a[10];

int main() {
	rd(n);
	for (int i = 1; i <= 9; ++i) rd(a[i]);
	int m = 1;
	for (int i = 1; i <= n; ++i) {
		m = 1ll * m * i % mod;
		ct = (1ll * ct * 10 + 1) % mod;
	}
	long long res = 0;
	for (int i = 1; i <= 9; ++i) {
		int tmp = 1;
		for (int j = 1; j <= a[i]; ++j)
			tmp = 1ll * tmp * j % mod;
		m = 1ll * m * quickPow(tmp, mod - 2) % mod;
	}
	int invn = quickPow(n, mod - 2);
	m = 1ll * m * invn % mod;
	for (int i = 1; i <= 9; ++i) {
		res = (res + ((((1ll * m * a[i])% mod) * i)%mod) * ct) % mod;
	}
	print(res); puts("");
	return 0;
}
0