Home > Back-end >  Pat L1-009 N number sum (20 points) has been hard for the great god just to see a test point
Pat L1-009 N number sum (20 points) has been hard for the great god just to see a test point

Time:09-23

# include
using namespace std;
Int B_shu (long int b, long int a);
Int B_shu1 (long int b, long int a);
Int main ()
{
Long int all_fz=0;
Int N;
Long int z=1;//for the least common multiple
cin> N;
Long int a [100] [2];
for (int i=0; I & lt; N; I++)
{
Scanf_s (" % ld/% ld ", & amp; A [I] [0], & amp; A, [I] [1]).
If (a [I] [1]==0)
{
exit(0);
}
}//input
For (int x=0; X & lt; N; X++)
{
Int q=B_shu (z, a [x] [1]).
Z=q;
}//z for LCM;
for (int i=0; I & lt; N; I++)
{
A [I] [0]=(z/a [I] [1]) * a, [I] [0].
All_fz +=a, [I] [0].
}
Long int min_bs=B_shu1 (all_fz, z);
All_fz=all_fz/min_bs;
Z=z/min_bs;//the minimalist form
Long int zheng_s=all_fz % z;
If (zheng_s==0)
{
Cout}
The else
{
If (zheng_s & gt; 0)
{
If (all_fz/z!=0)
{
cout }
cout }
The else
If (all_fz/z!=0)
{
cout }
The else
{
cout }
}
Return 0;
}
Int B_shu (long int b, long int a)
{
Long int z=1;
Long int x=0;
Long int m, n;
M=b;
N=a;
While (z!=0)
{
Z=b % a;
B=a;
A=z;
}
X=m * n/b;
return x;
}
Int B_shu1 (long int b, long int a)
{
Long int z=1;
While (z!=0)
{
Z=b % a;
B=a;
A=z;
}
Return b;
}

CodePudding user response:

You can use the compiler debugging
  • Related