Submission #00257


ソースコード

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
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <bitset>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class F> auto recur(F f) { return [f](auto... a){ return f(f, a...); }; }
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T>
T pow(T x, ll n, T r = 1) {
while (n) {
if (n & 1) r *= x;
x *= x;
n >>= 1;
}
return r;
}
template<uint MD>
struct ModInt {
uint v;
ModInt() : v{0} {}
ModInt(ll v) : v{normS(v%MD+MD)} {}
explicit operator bool() const {return v != 0;}
static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
static ModInt inv(const ModInt &x) {return pow(ModInt(x), MD-2);}
ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
ModInt operator/(const ModInt &r) const {return *this*inv(r);}
ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
ModInt& operator/=(const ModInt &r) {return *this=*this/r;}
};
template<uint MD> string to_string(ModInt<MD> m) {return to_string(m.v);}
using Mint = ModInt<TEN(9)+7>;
Mint calc(int a, ll b) {
if (b == 0) return Mint(0);
Mint c = calc(a, b/2);
c = c * pow(Mint(10), b/2) + c;
if (b % 2) {
c = c * Mint(10) + Mint(a);
}
return c;
}
Mint fact(int a) {
Mint c = 1;
for (int i = 1; i <= a; i++) {
c *= Mint(i);
}
return c;
}
int main() {
int n;
cin >> n;
V<ll> v[10];
for (int i = 0; i < n; i++) {
int a; ll b;
cin >> a >> b;
v[a].push_back(b);
}
if (n == 1 && v[0].size() == 1) {
cout << 0 << endl << 1 << endl;
return 0;
}
Mint off, cnt;
for (int i = 1; i < 10; i++) {
if (v[i].size() == 0) continue;
sort(begin(v[i]), end(v[i]), greater<ll>());
int buf = 0;
for (ll d: v[i]) {
if (d == v[i].back()) buf++;
}
off = calc(i, v[i].back());
//競技プログラミングやめます②
cnt = buf;
v[i].pop_back();
break;
}
// cout << off.v << " " << cnt.v << endl;
for (int i = 0; i < 10; i++) {
ll sm = 0;
for (ll d: v[i]) {
sm += d;
}
off *= pow(Mint(10), sm);
off += calc(i, sm);
cnt *= fact(v[i].size());
}
//競技プログラミングやめます
cout << off.v << endl << cnt.v << endl;
return 0;
}

ステータス

項目 データ
問題 0003 - repdigit
ユーザー名 yosupo06
投稿日時 2017-07-07 22:12:51
言語 C++17
状態 Wrong Answer
得点 0
ソースコード長 3051 Byte
最大実行時間 56 ms
最大メモリ使用量 1820 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01_sample1.in AC 11 ms 480 KB
1
01_sample2.in AC 16 ms 580 KB
1
01_sample3.in AC 20 ms 560 KB
1
02_handmake1.in AC 10 ms 528 KB
1
02_handmake2.in AC 10 ms 632 KB
1
02_handmake3.in AC 10 ms 476 KB
1
02_handmake4.in AC 10 ms 448 KB
1
02_handmake5.in AC 14 ms 428 KB
1
02_handmake6.in AC 11 ms 532 KB
1
02_handmake7.in AC 10 ms 500 KB
1
02_handmake8.in AC 10 ms 604 KB
1
02_handmake9.in AC 14 ms 708 KB
1
03_random1.in AC 14 ms 552 KB
1
03_random2.in AC 14 ms 524 KB
1
03_random3.in AC 13 ms 368 KB
1
03_random4.in AC 11 ms 464 KB
1
03_random5.in AC 14 ms 560 KB
1
03_random6.in AC 19 ms 528 KB
1
04_random1.in AC 10 ms 624 KB
1
04_random2.in AC 15 ms 596 KB
1
04_random3.in AC 17 ms 568 KB
1
04_random4.in WA 10 ms 412 KB
1
04_random5.in WA 12 ms 512 KB
1
04_random6.in WA 10 ms 480 KB
1
05_random1.in AC 53 ms 1600 KB
1
05_random2.in AC 48 ms 1712 KB
1
05_random3.in AC 50 ms 1808 KB
1
05_random4.in AC 56 ms 1680 KB
1
06_random1.in AC 56 ms 1736 KB
1
06_random3.in AC 55 ms 1820 KB
1