Submission #20603


ソースコード

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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include"iostream"
#include "string"
#include "algorithm"
#include "climits"
using namespace std;
const int MOD = 1000000007;
long long int one[60] = {};
long long int ten[60] = {};
long long int two[60] = {};
long long int Add(long long int a,long long int b) {
long long int box = 0;
while (b) {
for (int i = 59; i >= 0; i--) {
if (two[i] <= b) {
box *= ten[i];
box %= MOD;
box += one[i];
box %= MOD;
b -= two[i];
break;
}
}
}
box *= a;
box %= MOD;
return box;
}
int main() {
two[0] = 1;
for (int i = 1; i < 60; i++) {
two[i] = two[i - 1] * 2;
}
ten[0] = 10;
for (int i = 1; i < 60; i++) {
ten[i] = ten[i - 1] * ten[i - 1];
ten[i] %= MOD;
}
one[0] = 1;
for (int i = 1; i < 60; i++) {
one[i] = one[i - 1] * ten[i - 1] + one[i - 1];
one[i] %= MOD;
}
int N;
cin >> N;
int num[10] = {};
long long int far[10] = {};
pair<int, int>P = { INT_MAX,INT_MAX };
for (int i = 0; i < N; i++) {
int a, b;
cin >> a >> b;
if ((P.first != a || P.second != b) && a) P = min(P, { a, b });
num[a]++;
far[a] += b;
}
if (num[0] == N) {
cout << "0\n";
long long int box = 1;
for (int i = 1; i <= N; i++) {
box *= i;
box %= MOD;
}
cout << box << endl;
return 0;
}
if (!num[0]) {
long long int rank = 0;
long long int fig = 0;
long long int box = 1;
for (int i = 9; i >= 1; i--) {
fig += Add(i, far[i] + rank);
fig -= Add(i, rank);
fig += MOD;
fig %= MOD;
rank += far[i];
for (int j = 2; j <= num[i]; j++) {
box *= j;
box %= MOD;
}
}
cout << fig << endl;
cout << box << endl;
return 0;
}
if (num[0]) {
long long int a, b;
long long int rank = 0;
long long int fig = 0;
long long int box = 1;
a = P.first;
b = P.second;
num[a]--;
far[a] -= b;
for (int i = 9; i >= 0; i--) {
fig += Add(i, far[i] + rank);
fig -= Add(i, rank);
fig += MOD;
fig %= MOD;
rank += far[i];
for (int j = 2; j <= num[i]; j++) {
box *= j;
box %= MOD;
}
}
fig += Add(a, rank + b);
fig -= Add(a, rank);
fig += MOD;
fig %= MOD;
cout << fig << endl;
cout << box << endl;
}
return 0;
}

ステータス

項目 データ
問題 0758 - repdigit
ユーザー名 olphe
投稿日時 2017-07-05 02:10:01
言語 C++11
状態 Wrong Answer
得点 0
ソースコード長 2264 Byte
最大実行時間 55 ms
最大メモリ使用量 792 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01_sample1.in AC 17 ms 476 KB
1
01_sample2.in AC 17 ms 428 KB
1
01_sample3.in AC 10 ms 384 KB
1
02_handmake1.in AC 14 ms 336 KB
1
02_handmake2.in WA 11 ms 412 KB
1
02_handmake3.in AC 14 ms 492 KB
1
02_handmake4.in AC 13 ms 448 KB
1
02_handmake5.in AC 12 ms 396 KB
1
02_handmake6.in AC 17 ms 480 KB
1
02_handmake7.in AC 11 ms 564 KB
1
02_handmake8.in AC 12 ms 512 KB
1
02_handmake9.in AC 14 ms 592 KB
1
03_random1.in WA 14 ms 544 KB
1
03_random2.in WA 10 ms 624 KB
1
03_random3.in WA 11 ms 572 KB
1
03_random4.in AC 14 ms 528 KB
1
03_random5.in AC 11 ms 480 KB
1
03_random6.in AC 13 ms 560 KB
1
04_random1.in AC 14 ms 512 KB
1
04_random2.in AC 10 ms 596 KB
1
04_random3.in AC 14 ms 676 KB
1
04_random4.in AC 13 ms 624 KB
1
04_random5.in AC 13 ms 708 KB
1
04_random6.in AC 11 ms 792 KB
1
05_random1.in AC 55 ms 744 KB
1
05_random2.in AC 51 ms 692 KB
1
05_random3.in AC 51 ms 772 KB
1
05_random4.in AC 51 ms 728 KB
1
06_random1.in AC 47 ms 680 KB
1
06_random3.in AC 52 ms 636 KB
1