fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath> // untuk sin, cos, dll
  4. using namespace std;
  5.  
  6. int main() {
  7. int S; // sudut
  8. double V; // kecepatan awal
  9. const double g = 10.0;
  10.  
  11. // Input
  12. cin >> S;
  13. cin >> V;
  14.  
  15. // Konversi derajat ke radian
  16. double rad = S * M_PI / 180.0;
  17.  
  18. // Komponen kecepatan vertikal
  19. double Vy = V * sin(rad);
  20.  
  21. // Hitung waktu total
  22. double waktu = (2 * Vy) / g;
  23.  
  24. // Output dengan 3 angka di belakang koma
  25. cout << fixed << setprecision(3) << waktu << endl;
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 5316KB
stdin
12
12
stdout
0.499