/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'int main()':
/in/foo.cc:25:10: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if(k1<0&&k2>0||k1>0&&k2<0)
      ~~~~^~~~~~
/in/foo.cc:27:10: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if(c1<0&&c2>0||c1>0&&c2<0)
      ~~~~^~~~~~
# 状态 耗时 内存占用
#1 Accepted 4ms 384.0 KiB
#2 Accepted 4ms 384.0 KiB
#3 Wrong Answer 5ms 276.0 KiB
#4 Wrong Answer 3ms 220.0 KiB
#5 Wrong Answer 3ms 384.0 KiB
#6 Wrong Answer 4ms 256.0 KiB
#7 Wrong Answer 3ms 384.0 KiB
#8 Wrong Answer 4ms 356.0 KiB
#9 Wrong Answer 4ms 384.0 KiB
#10 Wrong Answer 4ms 348.0 KiB
#11 Wrong Answer 4ms 384.0 KiB
#12 Wrong Answer 4ms 360.0 KiB
#13 Wrong Answer 4ms 348.0 KiB
#14 Wrong Answer 4ms 268.0 KiB
#15 Wrong Answer 4ms 384.0 KiB
#16 Wrong Answer 4ms 256.0 KiB
#17 Wrong Answer 4ms 368.0 KiB
#18 Wrong Answer 3ms 364.0 KiB
#19 Wrong Answer 3ms 384.0 KiB

代码

#include <bits/stdc++.h>
using namespace std;
int a1,b1,a2,b2;
inline int gcd(int x,int y)
{
    while(x!=y)
    {
        if(x>y) x=x-y;
        else y=y-x;
    }
    return x;
}
int main()
{
	while(cin>>a1>>b1>>a2>>b2)
	{
		if(a1==a2||b1==b2)
		{
			cout<<"Error"<<endl;
			continue;
		}
		int k1=b2-b1,k2=a2-a1;
		int c1=b1*a2-a1*b2,c2=a2-a1;
		int fk=0,fc=0;
		if(k1<0&&k2>0||k1>0&&k2<0)
			fk=1;
		if(c1<0&&c2>0||c1>0&&c2<0)
			fc=1;
		k1=abs(k1),k2=abs(k2);
		c1=abs(c1),c2=abs(c2);
		int gk=gcd(k1,k2);
		int gc=gcd(c1,c2);
		k1/=gk,k2/=gk;
		c1/=gc,c2/=gc;
		cout<<"y=";
		if(fk) cout<<"-";
		if((k1==1&&k2!=1)||(k1!=1)) cout<<k1;
		if(k2!=1) cout<<"/"<<k2;
		cout<<"x";
		if(c1==0) cout<<endl;
		else
		{
			if(fc) cout<<"-";
			else cout<<"+";
			cout<<c1;
			if(c2!=1) cout<<"/"<<c2;
			cout<<endl;
		}
	}
}

信息

递交者
类型
递交
题目
数学弱智题 T3
题目数据
下载
语言
C++
递交时间
2017-11-03 09:36:06
评测时间
2017-11-03 09:36:06
评测机
分数
10
总耗时
79ms
峰值内存
384.0 KiB