RE?蒟蒻求助!!

P1888 三角函数

$AC$代码: ```cpp #include <bits/stdc++.h> using namespace std; int gcd(int m, int n) { return m==n?m:gcd(max(m,n)-min(m,n),min(m,n)); } int main() { int a[4]; cin>>a[1]>>a[2]>>a[3]; int max=a[1]; for(int i=2; i<=3; i++) if(a[i]>max) max=a[i]; int min=a[1]; for(int i=2; i<=3; i++) if(a[i]<min && a[i]!=max) min=a[i]; int x,y; x=max/gcd(min,max); y=min/gcd(min,max); cout<<y<<"/"<<x; return 0; } ```
by Eason_AC @ 2018-12-01 17:18:40


跳出循环时d=0,然后就RE了
by Hope2075 @ 2018-12-01 17:19:37


@[i_m_a_](/space/show?uid=86649) 你跳出循环是d=0,然后又拿a除以d,除以0当然RE咯
by SfumatoCannon_ @ 2018-12-01 17:23:29


@[i_m_a_](/space/show?uid=86649) 你直接输出e和f不就行了
by SfumatoCannon_ @ 2018-12-01 17:24:19


给一份WA代码…… (注意:去掉输出中间变量还是WA) ```cpp #include<bits/stdc++.h> using namespace std; int main() { long long a,b,c,d,e,f; cin>>a>>b>>c; if(a>c){e=a;f=c;}; if(a==c){e=a;f=c;}; if(a<c){e=c;f=a;}; //cout<<f; d=e%f; while(d!=0) { e=f; f=d; d=e%f; cout<<f<<endl; } cout<<d<<endl; a=a/f; c=c/f; cout<<a<<"/"<<c; return 0; } ```
by Hope2075 @ 2018-12-01 17:24:20


@[SfumatoCannon_](/space/show?uid=125429) 这不是我发的讨论……
by Hope2075 @ 2018-12-01 17:24:46


~~~~蒟蒻大悟~~~~
by KasuganoSora @ 2018-12-01 17:25:07


@[i_m_a_](/space/show?uid=86649) @错人了,尴尬
by SfumatoCannon_ @ 2018-12-01 17:25:34


需要对三个数排序 ~~int a[3]~~ ~~sort(a,a+3)~~
by Hope2075 @ 2018-12-01 17:26:38


爆零了······```cpp #include<bits/stdc++.h> using namespace std; int main() { long long a,b,c,d,e,f; cin>>a>>b>>c; if(a>c){e=a;f=c;} if(a==c){e=a;f=c;} if(a<c){e=c;f=a;} d=e%f; while(d!=0) { e=f; f=d; d=e%f; } cout<<e<<"/"<<f; return 0; } ```
by KasuganoSora @ 2018-12-01 17:28:00


| 下一页