# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864372 | AgentPengin | Lucky Numbers (RMI19_lucky) | C++14 | 0 ms | 400 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: AgentPengin ( Độc cô cầu bại )
* created: 23.12.2022 10:08:02
* too lazy to update time
**/
#include<bits/stdc++.h>
#define EL '\n'
#define fi first
#define se second
#define NAME "NAME"
#define ll long long
#define lcm(a,b) (a/gcd(a,b))*b
#define db(val) "["#val" = " << (val) << "] "
#define bend(v) (v).begin(),(v).end()
#define sz(v) (int)(v).size()
#define ex exit(0)
using namespace std;
const ll mod = 1e9 + 7;
const int inf = 0x1FFFFFFF;
const int MAXN = 105;
int n,q,a[MAXN],target;
ll dp[MAXN][2][2];
ll f(int id,bool lower,bool one) {
if (id == (target + 1)) {
return 1;
}
ll &res = dp[id][lower][one];
if (res != -1) return res;
res = 0;
int up = (lower == true ? 9 : a[id]);
for (int dig = 0;dig <= up;dig++) {
bool nxt_lower = lower || (dig < a[id]);
if (dig == 3 && one) continue;
res = (res + f(id + 1,nxt_lower,dig == 1)) % mod;
}
return res;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
if (ifstream(NAME".inp")) {
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
cin >> n >> q;
for (int i = 1;i <= n;i++) {
char c;
cin >> c;
a[i] = c - '0';
}
target = n;
memset(dp,-1,sizeof dp);
cout << f(1,0,0) << EL;
while(q--) {
int type;
cin >> type;
if (type == 2) {
int pos,val;
cin >> pos >> val;
a[pos] = val;
} else {
int l,r;
cin >> l >> r;
target = r;
memset(dp,-1,sizeof dp);
cout << f(l,0,0) << EL;
}
}
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
// agent pengin wants to take apio (with anya-san)
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |