Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<string>
- #include<cstdio>
- #include<fstream>
- #include<iomanip>
- using namespace std;
- int mouse(int n,int m);
- int main()
- {
- int n,m,num;
- while(cin>>n>>m)
- {
- num=mouse(n,m);
- cout<<n<<" "<<m<<" "<<num<<endl;
- }
- }
- int mouse(int n,int m)
- {
- int month,ans[40];
- ans[0]=n;
- for(month=1;month<=m;month++)
- {
- if(month==1)
- {
- ans[1]=ans[0]+ans[0]/2*3;
- }
- else if(month==2)
- {
- ans[2]=ans[1]+(ans[1]/2)*3;
- }
- else if(month==3)
- {
- ans[3]=ans[2]+(ans[2]/2*3)-n;
- }
- else
- {
- ans[month]=ans[month-1]+(ans[month-1]/2*3)-(ans[month-4]/2*3);
- }
- }
- return ans[m];
- }
Add Comment
Please, Sign In to add comment