Submission #00119


ソースコード

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
#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){
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 + cmin * cur)%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 + i * cur)%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:14:07
言語 C++17
状態 Wrong Answer
得点 0
ソースコード長 1413 Byte
最大実行時間 52 ms
最大メモリ使用量 2240 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01_sample1.in AC 17 ms 480 KB
1
01_sample2.in AC 14 ms 444 KB
1
01_sample3.in AC 14 ms 536 KB
1
02_handmake1.in AC 17 ms 504 KB
1
02_handmake2.in AC 17 ms 472 KB
1
02_handmake3.in AC 14 ms 440 KB
1
02_handmake4.in AC 12 ms 400 KB
1
02_handmake5.in AC 10 ms 500 KB
1
02_handmake6.in AC 11 ms 596 KB
1
02_handmake7.in AC 15 ms 564 KB
1
02_handmake8.in AC 11 ms 528 KB
1
02_handmake9.in AC 10 ms 628 KB
1
03_random1.in AC 10 ms 724 KB
1
03_random2.in AC 10 ms 560 KB
1
03_random3.in AC 10 ms 520 KB
1
03_random4.in AC 12 ms 616 KB
1
03_random5.in AC 11 ms 580 KB
1
03_random6.in AC 16 ms 548 KB
1
04_random1.in AC 14 ms 644 KB
1
04_random2.in AC 17 ms 608 KB
1
04_random3.in AC 14 ms 708 KB
1
04_random4.in WA 10 ms 676 KB
1
04_random5.in WA 15 ms 640 KB
1
04_random6.in WA 17 ms 736 KB
1
05_random1.in AC 50 ms 2240 KB
1
05_random2.in AC 47 ms 2180 KB
1
05_random3.in AC 50 ms 1996 KB
1
05_random4.in AC 49 ms 2072 KB
1
06_random1.in AC 52 ms 2148 KB
1
06_random3.in AC 51 ms 2088 KB
1