Submission #00250
ソースコード
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 | #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 = fact(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 << " " << cnt.v << endl; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - repdigit |
ユーザー名 | yosupo06 |
投稿日時 | 2017-07-07 22:10:55 |
言語 | C++17 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 2965 Byte |
最大実行時間 | 52 ms |
最大メモリ使用量 | 1808 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
01_sample1.in | WA | 21 ms | 480 KB |
1
|
01_sample2.in | WA | 13 ms | 456 KB |
1
|
01_sample3.in | AC | 13 ms | 428 KB |
1
|
02_handmake1.in | WA | 14 ms | 404 KB |
1
|
02_handmake2.in | WA | 17 ms | 512 KB |
1
|
02_handmake3.in | WA | 11 ms | 480 KB |
1
|
02_handmake4.in | WA | 14 ms | 452 KB |
1
|
02_handmake5.in | WA | 14 ms | 552 KB |
1
|
02_handmake6.in | WA | 15 ms | 528 KB |
1
|
02_handmake7.in | WA | 12 ms | 376 KB |
1
|
02_handmake8.in | WA | 15 ms | 480 KB |
1
|
02_handmake9.in | WA | 11 ms | 456 KB |
1
|
03_random1.in | WA | 12 ms | 556 KB |
1
|
03_random2.in | WA | 12 ms | 520 KB |
1
|
03_random3.in | WA | 12 ms | 488 KB |
1
|
03_random4.in | WA | 12 ms | 456 KB |
1
|
03_random5.in | WA | 13 ms | 556 KB |
1
|
03_random6.in | WA | 14 ms | 532 KB |
1
|
04_random1.in | WA | 14 ms | 504 KB |
1
|
04_random2.in | WA | 13 ms | 472 KB |
1
|
04_random3.in | WA | 11 ms | 440 KB |
1
|
04_random4.in | WA | 12 ms | 664 KB |
1
|
04_random5.in | WA | 11 ms | 636 KB |
1
|
04_random6.in | WA | 24 ms | 604 KB |
1
|
05_random1.in | WA | 52 ms | 1724 KB |
1
|
05_random2.in | WA | 51 ms | 1708 KB |
1
|
05_random3.in | WA | 51 ms | 1676 KB |
1
|
05_random4.in | WA | 50 ms | 1680 KB |
1
|
06_random1.in | WA | 51 ms | 1724 KB |
1
|
06_random3.in | WA | 49 ms | 1808 KB |
1
|