//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define int long long
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100002;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,dp[li][4][4];
int cev;
string s;
vector<int> v;
inline int add(int x,int y){
if(x+y>=mod)return x+y-mod;
return x+y;
}
inline int f(int sira,int kucuk,int bir){
int cevv=0;
if(sira==n)return 1;
if(~dp[sira][kucuk][bir])return dp[sira][kucuk][bir];
for(int i=0;i<=s[sira]-'0';i++){
if(bir && i==3)continue;
cevv=add(cevv,f(sira+1,(i<s[sira]-'0'?1:kucuk),(i==1?1:0)));
}
if(kucuk){
for(int i=s[sira]-'0'+1;i<=9;i++){
if(bir && i==3)continue;
cevv=add(cevv,f(sira+1,(i<s[sira]-'0'?1:kucuk),(i==1?1:0)));
}
}
return dp[sira][kucuk][bir]=cevv;
}
main(void){
fio();
memset(dp,-1,sizeof(dp));
cin>>n>>t;
cin>>s;
cout<<f(0,0,0)<<endl;
while(t--){
int x,y,z;
cin>>z>>x>>y;
n=y;
cout<<f(x-1,0,0)<<endl;
}
return 0;
}
Compilation message
lucky.cpp:57:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
57 | main(void){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
12800 KB |
Output is correct |
2 |
Correct |
8 ms |
12800 KB |
Output is correct |
3 |
Correct |
7 ms |
12800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
12800 KB |
Output is correct |
2 |
Correct |
8 ms |
12800 KB |
Output is correct |
3 |
Correct |
7 ms |
12800 KB |
Output is correct |
4 |
Correct |
7 ms |
12832 KB |
Output is correct |
5 |
Correct |
7 ms |
12800 KB |
Output is correct |
6 |
Correct |
7 ms |
12800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
13568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
13568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
12800 KB |
Output is correct |
2 |
Correct |
8 ms |
12800 KB |
Output is correct |
3 |
Correct |
7 ms |
12800 KB |
Output is correct |
4 |
Correct |
7 ms |
12832 KB |
Output is correct |
5 |
Correct |
7 ms |
12800 KB |
Output is correct |
6 |
Correct |
7 ms |
12800 KB |
Output is correct |
7 |
Incorrect |
13 ms |
13568 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
12800 KB |
Output is correct |
2 |
Correct |
8 ms |
12800 KB |
Output is correct |
3 |
Correct |
7 ms |
12800 KB |
Output is correct |
4 |
Correct |
7 ms |
12832 KB |
Output is correct |
5 |
Correct |
7 ms |
12800 KB |
Output is correct |
6 |
Correct |
7 ms |
12800 KB |
Output is correct |
7 |
Incorrect |
13 ms |
13568 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |