Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n, k;
- cin >> n >> k;
- if(n <= 2){
- cout << 1 << "\n";
- } else{
- int64_t seeds = k, plants = 1;
- for(int i = 3; i <= n; i++){
- int64_t tmp = plants;
- plants += seeds;
- seeds = tmp*k;
- }
- cout << plants << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement