fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin>>t;
  8. while(t--){
  9. int n,q;
  10. cin>>n>>q;
  11. string s;
  12. cin>>s;
  13. int l, r,cur=0;
  14. double x=0,y=0;
  15. for(int i=0;i<q;i++){
  16. cin>>l>>r;
  17. x=0;y=0;cur=0;
  18. for(int j=l-1;j<r;j++){
  19. int an = s[j]-'0';
  20. cur+=an*60;
  21. cur=cur%360;
  22. x=x+cos(cur*3.14159265/180);
  23. y=y+sin(cur*3.14159265/180);
  24. }
  25. cout<<fixed<<setprecision(8)<<x<<" ";
  26. cout<<fixed<<setprecision(8)<<y<<endl;
  27. }
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 4552KB
stdin
1
3 3
012
1 1
1 2
2 2
stdout
1.00000000 0.00000000
1.50000000 0.86602540
0.50000000 0.86602540