tag:blogger.com,1999:blog-4866159599909787379.post1373451080966176879..comments2023-09-17T06:25:46.688-07:00Comments on Spoj Solutions: Crucial Equationwhishkyhttp://www.blogger.com/profile/14897454400996798149noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-4866159599909787379.post-47955369976138106762015-07-01T22:34:04.487-07:002015-07-01T22:34:04.487-07:00#include
using namespace std;
int gcd(int big,int...#include <br />using namespace std;<br />int gcd(int big,int small)<br />{<br /> for(int i=small;i>=1;i--)<br /> {<br /> if(big%i==0)<br /> {<br /> return(i);<br /> }<br /> <br /> }<br />}<br /><br /><br /><br /><br /><br />int main() {<br /><br />int t;<br />cin>>t;<br />int a,b,c;<br />int g;<br />for(int i=1;i<=t;i++)<br />{<br /> cin>>a>>b>>c;<br /> if (a>b)<br /> {g=gcd(a,b);<br /> <br /> }<br /> else<br /> {<br /> g=gcd(b,a);<br /> }<br /> if(c%g==0)<br /> {<br /> cout<<"Case "<<i<<": Yes";<br /> }<br /> else<br /> { cout<<"Case "<<i<<": No";}<br /> cout<<"\n";<br />}<br /> return 0;<br />}<br />kn25https://www.blogger.com/profile/16901332773118161042noreply@blogger.comtag:blogger.com,1999:blog-4866159599909787379.post-85848080532752445492015-07-01T22:32:28.988-07:002015-07-01T22:32:28.988-07:00#include
using namespace std;
int gcd(int big,int...#include <br />using namespace std;<br />int gcd(int big,int small)<br />{<br /> for(int i=small;i>=1;i--)<br /> {<br /> if(big%i==0)<br /> {<br /> return(i);<br /> }<br /> <br /> }<br />}<br /><br /><br /><br /><br /><br />int main() {<br /><br />int t;<br />cin>>t;<br />int a,b,c;<br />int g;<br />for(int i=1;i<=t;i++)<br />{<br /> cin>>a>>b>>c;<br /> if (a>b)<br /> {g=gcd(a,b);<br /> <br /> }<br /> else<br /> {<br /> g=gcd(b,a);<br /> }<br /> if(c%g==0)<br /> {<br /> cout<<"Case "<<i<<": Yes";<br /> }<br /> else<br /> { cout<<"Case "<<i<<": No";}<br /> cout<<"\n";<br />}<br /> return 0;<br />}<br />kn25https://www.blogger.com/profile/16901332773118161042noreply@blogger.comtag:blogger.com,1999:blog-4866159599909787379.post-24952335085470154682015-07-01T22:29:26.093-07:002015-07-01T22:29:26.093-07:00#include
using namespace std;
int gcd(int big,int...#include <br />using namespace std;<br />int gcd(int big,int small)<br />{<br /> for(int i=small;i>=1;i--)<br /> {<br /> if(big%i==0)<br /> {<br /> return(i);<br /> }<br /> <br /> }<br />}<br /><br /><br /><br /><br /><br />int main() {<br /><br />int t;<br />cin>>t;<br />int a,b,c;<br />int g;<br />for(int i=1;i<=t;i++)<br />{<br /> cin>>a>>b>>c;<br /> if (a>b)<br /> {g=gcd(a,b);<br /> <br /> }<br /> else<br /> {<br /> g=gcd(b,a);<br /> }<br /> if(c%g==0)<br /> {<br /> cout<<"Case "<<i<<": Yes";<br /> }<br /> else<br /> { cout<<"Case "<<i<<": No";}<br /> cout<<"\n";<br />}<br /> return 0;<br />}<br />this code gives wrong answer. why?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4866159599909787379.post-59921915759240432412015-07-01T22:28:47.050-07:002015-07-01T22:28:47.050-07:00#include
using namespace std;
int gcd(int big,int...#include <br />using namespace std;<br />int gcd(int big,int small)<br />{<br /> for(int i=small;i>=1;i--)<br /> {<br /> if(big%i==0)<br /> {<br /> return(i);<br /> }<br /> <br /> }<br />}<br /><br /><br /><br /><br /><br />int main() {<br /><br />int t;<br />cin>>t;<br />int a,b,c;<br />int g;<br />for(int i=1;i<=t;i++)<br />{<br /> cin>>a>>b>>c;<br /> if (a>b)<br /> {g=gcd(a,b);<br /> <br /> }<br /> else<br /> {<br /> g=gcd(b,a);<br /> }<br /> if(c%g==0)<br /> {<br /> cout<<"Case "<<i<<": Yes";<br /> }<br /> else<br /> { cout<<"Case "<<i<<": No";}<br /> cout<<"\n";<br />}<br /> return 0;<br />}<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4866159599909787379.post-49362663339661564072015-05-17T16:00:07.352-07:002015-05-17T16:00:07.352-07:00I understand the logic , but don't know how it...I understand the logic , but don't know how it works .... please explain if possible.<br />munjalhttps://www.blogger.com/profile/18283210312291269744noreply@blogger.comtag:blogger.com,1999:blog-4866159599909787379.post-51973838631728420302015-05-17T15:58:45.490-07:002015-05-17T15:58:45.490-07:00thanks , thanks , munjalhttps://www.blogger.com/profile/18283210312291269744noreply@blogger.com