Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- #include<iostream>
- #include<cmath>
- #include<algorithm>
- #include<string>
- #define NIL -1;
- using namespace std;
- void przejdz(int pozycja,bool plyty[],int& sposoby,int cel)
- {
- int gdzie=pozycja;
- for(int rzut=1;rzut<=6;++rzut)
- {
- gdzie=pozycja;
- gdzie+=rzut;
- if(gdzie==cel)
- {
- ++sposoby;
- continue;
- }
- else if(gdzie>cel)
- return;
- else if(plyty[gdzie])
- przejdz(gdzie,plyty,sposoby,cel);
- }
- }
- int main()
- {
- int n,k;
- scanf("%d %d",&n,&k);
- bool plyty[n];
- //char wejscie[n];
- string wejscie;
- cin>>wejscie;
- for(int i=0;i<n;++i)
- {
- if(wejscie[i]=='1')
- plyty[i]=true;
- else
- plyty[i]=false;
- }
- int sposoby=0;
- int cel=n-1;
- int pozycja=0;
- przejdz(pozycja,plyty,sposoby,cel);
- printf("%d",sposoby%k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement