/ Randle /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 2ms 320.0 KiB
#2 Accepted 2ms 308.0 KiB
#3 Accepted 3ms 316.0 KiB
#4 Accepted 1ms 316.0 KiB
#5 Accepted 2ms 312.0 KiB
#6 Accepted 1ms 308.0 KiB
#7 Accepted 2ms 324.0 KiB
#8 Accepted 2ms 304.0 KiB
#9 Accepted 2ms 312.0 KiB
#10 Accepted 1ms 316.0 KiB
#11 Accepted 1ms 312.0 KiB
#12 Accepted 1ms 316.0 KiB
#13 Accepted 1ms 320.0 KiB
#14 Accepted 1ms 312.0 KiB
#15 Accepted 1ms 320.0 KiB
#16 Accepted 1ms 312.0 KiB
#17 Accepted 1ms 316.0 KiB
#18 Accepted 1ms 308.0 KiB
#19 Accepted 1ms 320.0 KiB

代码

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack> 
#include <ctime>

using namespace std;

long long X1,X2,Y1,Y2;
long long k1,k2;
bool fs;

long long gcd(long long a,long long b)
{
	long long r;
	while(b>0)
	{
		r=a%b;
		a=b;
		b=r;
	}
	return a;
}

long long abs_(long long x)
{
	if(x>0)return x;else return -x;
}

int main()
{
	
	while(cin>>X1>>Y1>>X2>>Y2)
	{
		if(X1==X2||Y1==Y2)
		{
			printf("Error\n");
			continue;
		}
		if(X1!=0)
		{
			swap(X1,X2);
			swap(Y1,Y2);
		}
		k1=Y1;	k2=X2;
		if((k1<0&&k2<0)||(k1>0&&k2>0))fs=1;else fs=0;
		k1=abs_(k1); k2=abs_(k2);
		long long ggg=gcd(k1,k2);
		k1/=ggg; k2/=ggg;
		printf("y=");
		if(fs)printf("-");
		if((k1==1&&k2!=1)||(k1!=1))cout<<k1;
		if(k2!=1)cout<<"/"<<k2;
		printf("x");
		if(Y1==0)printf("\n");
		else 
			if(Y1<0)cout<<Y1<<"\n";else cout<<"+"<<Y1<<"\n";
	}
	return 0;
}

信息

递交者
类型
递交
题目
数学弱智题 T3
题目数据
下载
语言
C++
递交时间
2017-10-02 13:58:18
评测时间
2017-10-02 13:58:18
评测机
分数
100
总耗时
37ms
峰值内存
324.0 KiB