fork download
  1. #include<iostream>
  2.  
  3. #include<iomanip>
  4.  
  5. using namespace std;
  6.  
  7. double prod(double m, double n){
  8.  
  9. if(n==0)
  10. return 0;
  11. else
  12. return m + prod(m,n-1);
  13.  
  14. // return n*m;
  15.  
  16. }
  17. int main()
  18. {
  19. int n;
  20. cin>>n;
  21. double a[n],b[n];
  22. double r[n];
  23. for(int i=0;i<n;i++){
  24. cin>>a[i]>>b[i];
  25. r[i]=prod(a[i],b[i]);
  26. }
  27. for(int i=0;i<n;i++){
  28. cout.setf(ios::fixed);
  29. cout<<setprecision(0)<<r[i]<<endl;
  30. }
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 3920KB
stdin
5
4 2
123 43
324 342
0 12
9999 12345
stdout
8
5289
110808
0
123437655