/ Randle /

记录详情

Time Exceeded

/in/foo.cc: In function 'int main()':
/in/foo.cc:26:10: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if(k1<0&&k2>0||k1>0&&k2<0)
      ~~~~^~~~~~
/in/foo.cc:28:10: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if(c1<0&&c2>0||c1>0&&c2<0)
      ~~~~^~~~~~
# 状态 耗时 内存占用
#1 Accepted 4ms 512.0 KiB
#2 Accepted 3ms 360.0 KiB
#3 Time Exceeded ≥1006ms ≥364.0 KiB
#4 Time Exceeded ≥1003ms ≥256.0 KiB
#5 Time Exceeded ≥1003ms ≥340.0 KiB
#6 Accepted 4ms 384.0 KiB
#7 Accepted 4ms 292.0 KiB
#8 Time Exceeded ≥1005ms ≥220.0 KiB
#9 Time Exceeded ≥1006ms ≥384.0 KiB
#10 Time Exceeded ≥1003ms ≥256.0 KiB
#11 Time Exceeded ≥1001ms ≥348.0 KiB
#12 Time Exceeded ≥1004ms ≥344.0 KiB
#13 Time Exceeded ≥1006ms ≥260.0 KiB
#14 Time Exceeded ≥1009ms ≥384.0 KiB
#15 Time Exceeded ≥1007ms ≥376.0 KiB
#16 Accepted 3ms 212.0 KiB
#17 Time Exceeded ≥1005ms ≥332.0 KiB
#18 Accepted 4ms 336.0 KiB
#19 Time Exceeded ≥1005ms ≥364.0 KiB

代码

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a1,b1,a2,b2;
inline ll gcd(ll x,ll 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;
		}
		ll k1=b2-b1,k2=a2-a1;
		ll c1=b1*a2-a1*b2,c2=a2-a1;
		ll 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);
		ll gk=gcd(k1,k2);
		ll 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:47
评测时间
2017-11-03 09:36:47
评测机
分数
30
总耗时
≥13094ms
峰值内存
≥512.0 KiB