+ 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++.....

23rd Jul 2021, 2:51 PM
Anikur Rahman
Anikur Rahman - avatar
9 odpowiedzi
+ 1
「HAPPY TO HELP」 Neither c1 nor c2 is given😑😑😑😑then how could I calculate😑😑😑???
23rd Jul 2021, 3:01 PM
Anikur Rahman
Anikur Rahman - avatar
+ 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
23rd Jul 2021, 3:04 PM
Anikur Rahman
Anikur Rahman - avatar
+ 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; }
23rd Jul 2021, 4:09 PM
Anikur Rahman
Anikur Rahman - avatar
+ 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
23rd Jul 2021, 10:04 PM
Angelo
Angelo - avatar
+ 1
Ohhh... i don't know how to find 2 unknown in 1 equation.
25th Jul 2021, 7:41 AM
Win Htay 🇲🇲
Win Htay 🇲🇲 - avatar
+ 1
Win Htay 🇲🇲 I gave a solution in comment. Please check out
25th Jul 2021, 7:42 AM
Anikur Rahman
Anikur Rahman - avatar
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
23rd Jul 2021, 3:02 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
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.
23rd Jul 2021, 3:06 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
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
24th Jul 2021, 4:24 PM
Hamdan Farooq
Hamdan Farooq - avatar