又一道水题,找出规律就行了
#include "iostream" using namespace std; int work(int m,int n){ //cout<<m<<' '<<n<<endl; if(m==1)return n+2; if(m==2)return 2*n+3; if(m==3&&n==1)return 13; if(m==3&&n!=1)return 2*work(3,n-1)+3; } int main(){ int m,n; while(cin>>m>>n){ cout<<work(m,n)<<endl; } }