Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int Ncnt2(int N,int K);
- int Ncnt(int N,int K) //не можем ставить 0
- {
- if (N==1) return K-1;
- return (K-1)*Ncnt2(N-1,K);
- }
- int Ncnt2(int N,int K) //можем ставить 0
- {
- if (N==1) return K;
- return (K-1)*Ncnt2(N-1,K)+Ncnt(N-1,K);
- }
- int main()
- {
- int N,K;
- cin>>N>>K;
- cout<<Ncnt(N,K);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement