+ 4
How to solve this one???
I have a equation --- n = c1 + (c2 * 2) How to calculate the value of c1 and c2...?? Here n is given. Can anyone give me any algorithm for this.....not the full code but just algorithm. It will bev more helpfull if it is in c or python3. Not in c++.....
9 Respostas
+ 1
「HAPPY TO HELP」
Neither c1 nor c2 is given😑😑😑😑then how could I calculate😑😑😑???
+ 1
C1,C2 and n all are integer.
n is the result of c1+(c2*2)
I need to find out the value of c1 and c2.....here the value of n is given as input
+ 1
「HAPPY TO HELP」
A.S.
NotAPythonNinja
Here is my approach in c:
#include<stdio.h>
int main()
{
int k,a,b,n,x;
scanf("%d",&k);
int i;
for(i=1;i<=k;i++){
scanf("%d",&n);
a=n/3;
b=a+1;
x=n%3;
if(x==0){
printf("%d %d",a,a);
}
else{
if(a+(b*2)==k){
printf("%d %d",b,a);
}
else{
printf("%d %d",a,b);
}
}
}
return 0;
}
+ 1
There is no need for an algorithm, you can clearly see that a solution is
c1=n%2
c2=n//2
Just think what happens when n is even and when it's odd
Or even easier c1=n and c2=0
All the other solutions are
c1' = c1 + 2k
c2' = c2 - k
With k an arbitrary integer
Edit:
For completeness I'll link the Wikipedia page for diophantine linear equations
https://en.m.wikipedia.org/wiki/Diophantine_equation
+ 1
Ohhh... i don't know how to find 2 unknown in 1 equation.
+ 1
Win Htay 🇲🇲
I gave a solution in comment. Please check out
0
I think your question is not complete how can u find two values in single equation bcez in your case c1 and c2 both are missing tell actually what are c1 and c2 what is n
0
Anikur Rahman your question is incomplete or may be one more value will be given it may be any integer value or floating ...... If this is your question then its not possible to find solutions using single equation.
0
First one equation containing 2 unknowns could not be solved unless there is some condition for example c1 is twice c2 or c1 is half of the n or etc. Please provide complete question I think your question is not complete. Thanks