Min min senior want to get some yellow, green and blue orbs, known to synthesize a yellow orbs need two yellow crystal, synthesis of a green orbs need a yellow crystals and a blue crystal, synthesis of a blue orbs need three blue crystal
Now min min senior has A yellow crystal and B blue crystal, min min senior want A yellow orbs x, y, A green orbs and z A blue orbs, min min senior, please calculate the minimum also need the number of crystal, the first line contains two Numbers A and B (0? Or less? A,? B? Or less? 10 ^ 9), representing the existing number of yellow crystal, and the number of blue crystal,
The second line has three Numbers x, y, and z (0? Or less? X,? Y,? Z? Or less? 10 ^ 9) - represents the final number of yellow, green and blue magic ball to get
Input
4 3
2 1 1
The Output
2
Input
3 and 9
1 1 3
The Output
1
Input
12345678, 87654321,
43043751 1000000000 53798715
The Output
2147483648
I have made the wrong code,
#include
Int main ()
{unsigned long long int a, b, x, y, z, n, m, blue=0, yellow=0, t;
The scanf (" % LLD % LLD, & amp; A, & amp; B);
The scanf (" % LLD % % LLD LLD ", & amp; X, & amp; Y, & amp; Z);
N=b/3;
T=b % 3.
If (n<=z)
Blue=3 * (z - n) + y - t;
If (n> Z& & (n - z) & lt;=y)
Blue=y - (n - z) - t;
If (n> Z& & (n - z) & gt; Y)
Blue=0;
If (a<=y)
Yellow=y - a + 2 * x;
If (a> Y& & (a - y) % 2==0)
Yellow=(x - (a - y)/2) * 2;
If (a> Y& & (a - y) % 2!=0)
Yellow=(x - (a - y)/2) * 2-1;
M=blue + yellow;
Printf (" % LLD ", m);
return 0;
}
CodePudding user response:
Your program defines a heap of integer,N=b/3; Are you sure that there will be no problem?
You how so trouble don't want to complex the problem of simple
For your reference
int main () {
int a,b;
While (the scanf (" % d % d ", & amp; A, & amp; B)!=(EOF)
{
Unsigned int x, y, z;
The scanf (" % u % u % du ", & amp; X, & amp; Y, & amp; Z);
Printf (" % u \ n ", 2 * (x + y) + 3 * z - a - b).
}
}