又掉分了0 0。
Parsley, sage, rosemary and thyme.
Remember me to one who lives there.
He once was the true love of mine.
Willem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.
Willem asks his friend, Grick for directions, Grick helped them, and gave them a task.
Although the girl wants to help, Willem insists on doing it by himself.
Grick gave Willem a string of length n.
Willem needs to do m operations, each operation has four parameters l, r, c1, c2, which means that all symbols c1 in range [l, r] (froml-th to r-th, including l and r) are changed into c2. String is 1-indexed.
Grick wants to know the final string after all the m operations.
The first line contains two integers n and m (1 ≤ n, m ≤ 100).
The second line contains a string s of length n, consisting of lowercase English letters.
Each of the next m lines contains four parameters l, r, c1, c2 (1 ≤ l ≤ r ≤ n, c1, c2 are lowercase English letters), separated by space.
Output string s after performing m operations described above.
3 1
ioi
1 1 i n
noi
5 3
wxhak
3 3 h x
1 5 x a
1 3 w g
gaaak
中规中矩的水题。
1 #include<bits/stdc++.h> 2 using namespace std; 3 char s[10000]; 4 int main() 5 { 6 int n,m,k,T,l,r; 7 char o,p; 8 scanf("%d%d",&n,&m); 9 scanf("%s",s); 10 for(int i=1;i<=m;i++) 11 { 12 scanf("%d%d %c %c",&l,&r,&o,&p); 13 for(int i=l-1;i<=r-1;i++) 14 if(s[i]==o) 15 s[i]=p; 16 } 17 printf("%s\n",s); 18 return 0; 19 }
— I experienced so many great things.
— You gave me memories like dreams... But I have to leave now...
— One last request, can you...
— Help me solve a Codeforces problem?
— ......
— What?
Chtholly has been thinking about a problem for days:
If a number is palindrome and length of its decimal representation without leading zeros is even, we call it a zcy number. A number ispalindrome means when written in decimal representation, it contains no leading zeros and reads the same forwards and backwards. For example 12321 and 1221 are palindromes and 123 and 12451 are not. Moreover, 1221 is zcy number and 12321 is not.
Given integers k and p, calculate the sum of the k smallest zcy numbers and output this sum modulo p.
Unfortunately, Willem isn't good at solving this kind of problems, so he asks you for help!
The first line contains two integers k and p (1 ≤ k ≤ 105, 1 ≤ p ≤ 109).
Output single integer — answer to the problem.
2 100
33
5 30
15
枚举下各位的情况就好了,最多12位的回文数。
1 #include<bits/stdc++.h> 2 #define clr(x) memset(x,0,sizeof(x)) 3 #define clr_1(x) memset(x,-1,sizeof(x)) 4 #define LL long long 5 #define INF 0x3f3f3f3f 6 using namespace std; 7 int n,k; 8 LL ans,mod; 9 void dfs(int lf,int sign,LL num) 10 { 11 if(k==0) 12 return ; 13 if(lf==0) 14 { 15 LL p=num; 16 while(p) 17 { 18 num*=10; 19 num+=p%10; 20 p/=10; 21 } 22 ans=(ans+num%mod)%mod; 23 k--; 24 return ; 25 } 26 if(sign) 27 for(int i=1;i<=9;i++) 28 dfs(lf-1,0,num*10+i); 29 else 30 for(int i=0;i<=9;i++) 31 dfs(lf-1,0,num*10+i); 32 return ; 33 } 34 int main() 35 { 36 scanf("%d%lld",&k,&mod); 37 ans=0; 38 for(int p=1;p<=6;p++) 39 { 40 if(k==0) 41 break; 42 dfs(p,1,0); 43 } 44 printf("%lld\n",ans); 45 return 0; 46 }
Nephren is playing a game with little leprechauns.
She gives them an infinite array of strings, f0... ∞.
f0 is "What are you doing at the end of the world? Are you busy? Will you save us?".
She wants to let more people know about it, so she defines fi = "What are you doing while sending "fi - 1"? Are you busy? Will you send "fi - 1"?" for all i ≥ 1.
For example, f1 is
"What are you doing while sending "What are you doing at the end of the world? Are you busy? Will you save us?"? Are you busy? Will you send "What are you doing at the end of the world? Are you busy? Will you save us?"?". Note that the quotes in the very beginning and in the very end are for clarity and are not a part of f1.
It can be seen that the characters in fi are letters, question marks, (possibly) quotation marks and spaces.
Nephren will ask the little leprechauns q times. Each time she will let them find the k-th character of fn. The characters are indexed starting from 1. If fn consists of less than k characters, output '.' (without quotes).
Can you answer her queries?
The first line contains one integer q (1 ≤ q ≤ 10) — the number of Nephren's questions.
Each of the next q lines describes Nephren's question and contains two integers n and k (0 ≤ n ≤ 105, 1 ≤ k ≤ 1018).
One line containing q characters. The i-th character in it should be the answer for the i-th query.
3
1 1
1 2
1 111111111111
Wh.
5
0 69
1 194
1 139
0 47
1 66
abdef
10
4 1825
3 75
3 530
4 1829
4 1651
3 187
4 584
4 255
4 774
2 474
Areyoubusy