Submission #00122


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define reep(i,a,b) for(int i=a; i<b; i++)
#define MOD 1000000007LL
#define fi first
#define se second
using ll = long long;
using pll = pair<ll, ll>;
ll powmod(ll x, ll y) {
ll a = 1;
while(y) {
if(y & 1) a = a * x % MOD;
x = x * x % MOD;
y >>= 1;
}
return a;
}
void add(ll &x, ll y) {
(x += y + MOD) %= MOD;
}
void tim(ll &x, ll y) {
(x *= y) %= MOD;
}
ll g(ll a, ll b) {
ll ret = powmod(10, b);
add(ret, -1);
tim(ret, powmod(9, MOD - 2));
tim(ret, a);
return ret;
}
void func(ll &x, ll a, ll b) {
tim(x, powmod(10, b));
add(x, g(a, b));
}
int main() {
int n;
cin >> n;
vector<map<ll, ll>> ma(10);
rep(i, n) {
ll a, b;
cin >> a >> b;
ma[a][b]++;
}
ll ans1 = 0;
pll t(1, 1);
if(ma[0].size()){
reep(i, 1, 10) {
if(ma[i].size() == 0) continue;
for(pll x : ma[i]) {
func(ans1, i, x.fi);
t.fi = x.fi;
t.se = x.se;
ma[i][x.fi]--;
break;
}
break;
}
}
rep(i, 10) {
for(pll x : ma[i]) {
rep(j, x.se) func(ans1, i, x.fi);
}
}
cout << ans1 << endl;
ll ans2 = t.se;
vector<ll> functional(n + 10);
functional[0] = 1;
reep(i, 1, n + 10) {
functional[i] = functional[i - 1] * i % MOD;
functional[i] %= MOD;
}
rep(i, 10) {
ll sum = 0;
for(pll x : ma[i]) {
sum += x.se;
}
tim(ans2, functional[sum]);
}
cout << ans2 << endl;
}

ステータス

項目 データ
問題 0003 - repdigit
ユーザー名 yellow_jam
投稿日時 2017-07-07 21:15:51
言語 C++11
状態 Accepted
得点 100
ソースコード長 1503 Byte
最大実行時間 144 ms
最大メモリ使用量 7692 KB

セット

セット 得点 Cases
1 ALL 100 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01_sample1.in AC 12 ms 480 KB
1
01_sample2.in AC 13 ms 452 KB
1
01_sample3.in AC 30 ms 424 KB
1
02_handmake1.in AC 18 ms 400 KB
1
02_handmake2.in AC 10 ms 632 KB
1
02_handmake3.in AC 10 ms 608 KB
1
02_handmake4.in AC 13 ms 448 KB
1
02_handmake5.in AC 10 ms 556 KB
1
02_handmake6.in AC 14 ms 532 KB
1
02_handmake7.in AC 15 ms 512 KB
1
02_handmake8.in AC 12 ms 484 KB
1
02_handmake9.in AC 12 ms 460 KB
1
03_random1.in AC 11 ms 560 KB
1
03_random2.in AC 17 ms 780 KB
1
03_random3.in AC 11 ms 628 KB
1
03_random4.in AC 16 ms 724 KB
1
03_random5.in AC 10 ms 692 KB
1
03_random6.in AC 20 ms 660 KB
1
04_random1.in AC 15 ms 504 KB
1
04_random2.in AC 14 ms 724 KB
1
04_random3.in AC 15 ms 684 KB
1
04_random4.in AC 11 ms 648 KB
1
04_random5.in AC 14 ms 612 KB
1
04_random6.in AC 13 ms 576 KB
1
05_random1.in AC 128 ms 7584 KB
1
05_random2.in AC 123 ms 7692 KB
1
05_random3.in AC 138 ms 7668 KB
1
05_random4.in AC 135 ms 7640 KB
1
06_random1.in AC 144 ms 7616 KB
1
06_random3.in AC 121 ms 7596 KB
1