Submission #00192
ソースコード
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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | #include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #include <assert.h> #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector< int > VI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef vector<VI> VVI; typedef pair< int , int > P; typedef pair<ll,ll> PL; #define mod 1000000007 const int N = 200010; ll fact[N], invf[N]; ll add(ll x, ll y){ return (x+y)%mod; } ll mul(ll x, ll y){ return (x%mod)*(y%mod)%mod; } ll powll(ll x, ll y){ ll res = 1LL; while (y){ if (y & 1LL) res *= x; res %= mod; x = (x*x) % mod; y >>= 1LL; } return res; } ll divll(ll x, ll y){ return (x * powll(y,mod-2)) % mod; } ll nPr(ll n, ll r){ if (n < r || r < 0) return 0; return mul(fact[n], invf[n-r]); } ll nCr(ll n, ll r){ if (n < r || r < 0) return 0; return mul(mul(fact[n], invf[r]), invf[n-r]); } ll make(ll x, ll y){ ll ret = powll(10, y) - 1; return mul(divll(ret, 9), x); } int main() { int n; cin >> n; VL p[10]; REP(i,n){ int a, b; scanf ( "%d %d" , &a, &b); p[a].push_back(b); } fact[0] = invf[0] = 1; FOR(i,1,N-1){ fact[i] = (fact[i-1] * i) % mod; invf[i] = divll(invf[i-1], i); } ll ans = 0; REP(i,10) sort(ALL(p[i])); ll mi = -1, x = 0; // if (p[0].size() > 0){ FOR(i,1,9){ REP(j,p[i].size()){ mi = p[i][j]; REP(k,p[i].size()) x += (p[i][k] == mi); ans += make(i, p[i][j]); p[i].erase(p[i].begin()); i = 10; break ; } } // } if (n == 1 && ans == 0){ cout << 0 << endl << 1 << endl; return 0; } REP(i,10){ ll s = 0; REP(j,p[i].size()){ s += p[i][j]; } if (s == 0) continue ; ans = (mul(ans, powll(10, s)) + make(i, s)) % mod; } cout << ans << endl; ans = 1; if (p[0].size() != 0) ans = x; bool f = true ; REP(i,10){ if (p[i].size() == 0) continue ; if (f && p[0].size() == 0){ ans = mul(ans, fact[p[i].size() + 1]); f = false ; } else ans = mul(ans, fact[p[i].size()]); } cout << ans << endl; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0003 - repdigit |
ユーザー名 | TangentDay |
投稿日時 | 2017-07-07 21:45:33 |
言語 | C++11 |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 2770 Byte |
最大実行時間 | 53 ms |
最大メモリ使用量 | 4960 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 0 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
01_sample1.in | WA | 38 ms | 3552 KB |
1
|
01_sample2.in | AC | 39 ms | 3600 KB |
1
|
01_sample3.in | AC | 40 ms | 3648 KB |
1
|
02_handmake1.in | AC | 39 ms | 3692 KB |
1
|
02_handmake2.in | AC | 36 ms | 3620 KB |
1
|
02_handmake3.in | AC | 43 ms | 3668 KB |
1
|
02_handmake4.in | AC | 36 ms | 3724 KB |
1
|
02_handmake5.in | AC | 38 ms | 3644 KB |
1
|
02_handmake6.in | AC | 41 ms | 3564 KB |
1
|
02_handmake7.in | AC | 42 ms | 3612 KB |
1
|
02_handmake8.in | AC | 41 ms | 3664 KB |
1
|
02_handmake9.in | AC | 35 ms | 3588 KB |
1
|
03_random1.in | AC | 38 ms | 3636 KB |
1
|
03_random2.in | AC | 39 ms | 3680 KB |
1
|
03_random3.in | AC | 39 ms | 3728 KB |
1
|
03_random4.in | AC | 41 ms | 3772 KB |
1
|
03_random5.in | AC | 36 ms | 3692 KB |
1
|
03_random6.in | AC | 36 ms | 3736 KB |
1
|
04_random1.in | AC | 38 ms | 3784 KB |
1
|
04_random2.in | AC | 39 ms | 3832 KB |
1
|
04_random3.in | AC | 45 ms | 3880 KB |
1
|
04_random4.in | AC | 35 ms | 3792 KB |
1
|
04_random5.in | AC | 40 ms | 3836 KB |
1
|
04_random6.in | AC | 37 ms | 3884 KB |
1
|
05_random1.in | AC | 50 ms | 4960 KB |
1
|
05_random2.in | AC | 51 ms | 4892 KB |
1
|
05_random3.in | AC | 53 ms | 4936 KB |
1
|
05_random4.in | AC | 50 ms | 4888 KB |
1
|
06_random1.in | AC | 53 ms | 4624 KB |
1
|
06_random3.in | AC | 53 ms | 4912 KB |
1
|