fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdio>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int a,b,c,d;
  9.  
  10. inline double Func(long long k){
  11. return sin(a*k + b) + cos(c*k + d);
  12. }
  13.  
  14. int main(){
  15. int p,n;
  16. cin >> p >> a >> b >> c >> d >> n;
  17. double ans = 0;
  18. double MMax = -1e5;
  19. for (int i=1;i<=n;i++){
  20. double f = Func(i);
  21. MMax = max(MMax,f);
  22. ans = max(ans,MMax - f);
  23. }
  24. cout << setprecision(15) << ans*p;
  25. }
Time limit exceeded #stdin #stdout 5s 3096KB
stdin
Standard input is empty
stdout
Standard output is empty