按题目要求列方程,然后求解
一次方程组的求解,直接上代码吧
1 #include <iostream>
2
3 #include <iomanip>
4
5 #include<math.h>
6
7 using namespace std;
8
9
10 int main()
11
12 {
13
14 int t;
15
16 double n,m,a,b,c,d,x,y;
17
18 cin>>t;
19
20 while(t--)
21
22 {
23
24 cin>>n>>a>>b>>c>>d;
25
26 x=(d+a*n/b)/2;
27
28 x=x/a;
29
30 x=floor(x)+1;
31
32 y=x;
33
34 x=x*a-0.01;
35
36 m=(x-d)*(n-(y-1)*b)-c;
37
38 cout<<setprecision(2)<<fixed<<m<<endl;
39
40 }
41
42 return 0;
43
44 }