這個演算法一直超過時間...
#include <iostream>
using namespace std;
int main()
{
while(true)
{
int raid[4];
for(int i=0;i<=3;i++)
{
cin>>raid[i];
}
if(((raid[1]%raid[0]==0)||(raid[0]%raid[1]==0))&&((raid[1]%raid[2]==0)||(raid[2]%raid[1]==0)))
{
cout<<raid[3]*(raid[1]/raid[0]);
}
else
{
cout<<raid[3]+((raid[1]-raid[0]));
}
}
system("pause");
return 0;
}