Submission #00134


ソースコード

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
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n;++i)
using namespace std;
using ll = long long;
const ll mod = 1000000007LL;
ll fact[100010];
int a[100010],b[100010];
ll num[10];
ll digit[10];
int cmin = 10, len = 0;
ll power(ll a,ll n){
n %= (mod-1);
ll ret = 1LL;
while(n){
if(n&1) ret = ret * a % mod;
a = a * a % mod;
n >>= 1;
}
return ret;
}
int main(void){
int n;
cin >> n;
fact[0] = 1LL;
rep(i,n) fact[i+1] = 1LL * (i+1) * fact[i] % mod;
rep(i,n){
cin >> a[i] >> b[i];
num[a[i]]++;
digit[a[i]]+=b[i];
if(a[i]==0) continue;
if(cmin > a[i] or cmin == a[i] and len > b[i]){
cmin = a[i];
len = b[i];
}
}
if(n==1 and a[0] == 0 and b[0] == 1){
cout << 0 << endl;
cout << 1 << endl;
return 0;
}
const ll inine = power(9LL,mod-2);
{
ll ans = 0LL;
{
const ll ten = power(10,len);
const ll cur = (ten + mod -1) % mod * inine % mod;
ans = (ans * ten % mod + cmin * cur % mod)%mod;
}
digit[cmin]-=len;
rep(i,10){
const ll ten = power(10,digit[i]);
const ll cur = (ten + mod -1) % mod * inine % mod;
ans = (ans * ten % mod + i * cur % mod)%mod;
}
cout << ans << endl;
}
{
int cnt = 0;
rep(i,n) if(cmin == a[i] and len == b[i]) cnt++;
ll way = cnt;
num[cmin]--;
rep(i,10) way = 1LL * way * fact[num[i]] % mod;
cout << way << endl;
}
return 0;
}

ステータス

項目 データ
問題 0003 - repdigit
ユーザー名 hec
投稿日時 2017-07-07 21:21:15
言語 C++17
状態 Wrong Answer
得点 0
ソースコード長 1434 Byte
最大実行時間 57 ms
最大メモリ使用量 2228 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01_sample1.in AC 14 ms 476 KB
1
01_sample2.in AC 14 ms 440 KB
1
01_sample3.in AC 10 ms 532 KB
1
02_handmake1.in AC 14 ms 500 KB
1
02_handmake2.in AC 21 ms 472 KB
1
02_handmake3.in AC 13 ms 564 KB
1
02_handmake4.in AC 13 ms 664 KB
1
02_handmake5.in AC 15 ms 508 KB
1
02_handmake6.in AC 12 ms 472 KB
1
02_handmake7.in AC 11 ms 568 KB
1
02_handmake8.in AC 16 ms 660 KB
1
02_handmake9.in AC 14 ms 628 KB
1
03_random1.in AC 13 ms 464 KB
1
03_random2.in AC 13 ms 556 KB
1
03_random3.in AC 13 ms 648 KB
1
03_random4.in AC 14 ms 612 KB
1
03_random5.in AC 15 ms 448 KB
1
03_random6.in AC 17 ms 540 KB
1
04_random1.in AC 15 ms 636 KB
1
04_random2.in AC 12 ms 732 KB
1
04_random3.in AC 11 ms 692 KB
1
04_random4.in WA 12 ms 652 KB
1
04_random5.in WA 10 ms 620 KB
1
04_random6.in WA 14 ms 588 KB
1
05_random1.in AC 50 ms 2212 KB
1
05_random2.in AC 47 ms 2160 KB
1
05_random3.in AC 51 ms 2228 KB
1
05_random4.in AC 47 ms 2048 KB
1
06_random1.in AC 49 ms 2120 KB
1
06_random3.in AC 57 ms 2068 KB
1