杭电oj1049 根据规律 写几个就推出来了

来源:互联网 发布:微商做图软件有哪些 编辑:程序博客网 时间:2024/05/29 08:39
#include<iostream>
using namespace std;
int s(int a,int b,int c,int t);
int main()
{
 int n,u,d,min=1;
 while(cin>>n,cin>>u,cin>>d)
 {
  if(n==0)
  break;
  cout<<s(n,u,d,min)<<endl;
 }
 return 0;
}
int s(int a,int b,int c,int t)
{
 int m;
 if(t%2!=0)
 m=(t+1)/2*b-t/2*c;
 if(t%2==0)
 m=t/2*b-t/2*c;
 if(m>=a)
 return t;
 else
 {
  t++;
 s(a,b,c,t);
}
 
}
阅读全文
0 0
原创粉丝点击