Long long s1 (long long sum, long long k)
{
Long long I, sum1=0;
If (sum
Else if (sum==k)
Sum1=0;
Else if (sum> K)
for(i=1; Sum> k; I++)
{sum=sum % (k * I); }
Sum1=sum;
Return sum1;
}//to find the real need of sum1
Int main ()
{
Long long r, y, g, I, k, a, b;
Long long n, m, sum=0;
The scanf (" % l64d % % l64d l64d ", & amp; R, & amp; Y, & amp; g);
K=r + y + g;
The scanf (" % l64d ", & amp; n);
for(i=1; i<=n; I++)
{the scanf (" % l64d % l64d ", & amp; A, & amp; B);
M=s1 (sum, k);
If (a==0)
{sum=the sum a + b;
continue; }
If (a==1)
{if (b> M)
Sum=the sum of a + b - m;
Else if (m<=b + g)
Sum=sum;
The else sum=sum + k - m + b;
continue;
}
If (a==2)
{
If (m<=b + r)
Sum=the sum of a + b - m + r;
Else if (m<=b + r + g)
Sum=sum;
The else
Sum=sum + k - m + b + r;
continue;
}
If (a==3)
{
If (b> M)
Sum=sum;
Else if (m<=b + y + r)
Sum=sum + k - m - g + b;
The else sum=sum;
continue;
}
}
Printf (" % l64d ", sum);
}
CodePudding user response:
# include
Long long s1 (long long sum, long long k)
{
Long long I, sum1=0;
If (sumSum1=sum;
Else if (sum==k)
Sum1=0;
Else if (sum> K)
for(i=1; Sum> k; I++)
{sum=sum % (k * I); }
Sum1=sum;
Return sum1;
}//to find the real need of sum1
Int main (void)
{
Long long r, y, g, I, k, a, b;
Long long n, m, sum=0;
//the scanf (" % l64d % % l64d l64d ", & amp; R, & amp; Y, & amp; g);
The scanf (" % LLD % % LLD LLD ", & amp; R, & amp; Y, & amp; g);
K=r + y + g;
//the scanf (" % l64d ", & amp; n);
The scanf (" % LLD, & amp; n);
for(i=1; i<=n; I++)
{
//the scanf (" % l64d % l64d ", & amp; A, & amp; B);
The scanf (" % LLD % LLD, & amp; A, & amp; B);
M=s1 (sum, k);
If (a==0) {
Sum=the sum a + b;
continue;
}
If (a==1)
{if (b> M)
Sum=the sum of a + b - m;
Else if (m<=b + g)
Sum=sum;
The else sum=sum + k - m + b;
continue;
}
If (a==2)
{
If (m<=b + r)
Sum=the sum of a + b - m + r;
Else if (m<=b + r + g)
Sum=sum;
The else
Sum=sum + k - m + b + r;
continue;
}
If (a==3)
{
If (b> M)
Sum=sum;
Else if (m<=b + y + r)
Sum=sum + k - m - g + b;
The else
Sum=sum;
continue;
}
}
//printf (" % l64d ", sum);
Printf (" % LLD, sum);
}
For your reference ~
For the sum=sum; Suggest getting rid of