/ Randle /

记录详情

Runtime Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  while(scanf("%d %d %d %d",&x,&y,&z,&p)==4)
                            ~~         ^
/in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
/in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
/in/foo.cc:20:39: warning: format '%d' expects argument of type 'int*', but argument 5 has type 'long long int*' [-Wformat=]
# 状态 耗时 内存占用
#1 Runtime Error 3ms 316.0 KiB
#2 Wrong Answer 3ms 320.0 KiB
#3 Runtime Error 2ms 320.0 KiB
#4 Runtime Error 2ms 312.0 KiB
#5 Runtime Error 2ms 320.0 KiB
#6 Runtime Error 2ms 316.0 KiB
#7 Runtime Error 2ms 316.0 KiB
#8 Runtime Error 2ms 320.0 KiB
#9 Runtime Error 2ms 312.0 KiB
#10 Runtime Error 1ms 320.0 KiB
#11 Runtime Error 1ms 316.0 KiB
#12 Runtime Error 2ms 320.0 KiB
#13 Runtime Error 1ms 320.0 KiB
#14 Runtime Error 1ms 464.0 KiB
#15 Runtime Error 1ms 324.0 KiB
#16 Runtime Error 1ms 316.0 KiB
#17 Runtime Error 1ms 316.0 KiB
#18 Runtime Error 1ms 324.0 KiB
#19 Runtime Error 1ms 316.0 KiB

代码

#include<iostream>
#include<cmath>
using namespace std;
long long x,y,z,p,ans;
void work(int &x,int &y)
{
	for(int i=2;i<=sqrt(x)&&i<=sqrt(y);i++)
	{
		if(x%i==0&&y%i==0)
		{
			x/=i;
			y/=i;
			work(x,y);
			break;
		}
	}
}
int main()
{
	while(scanf("%d %d %d %d",&x,&y,&z,&p)==4)
	{
		if(x==z&&y==p)
		cout<<"Error"<<endl;
		else
		{
			int k2=p-y,k1=z-x;
			if(abs(k2)%abs(k1)==0)
			{
			    ans=k2/k1;
			    cout<<"y=";
				if(ans==-1)
				cout<<"-";
				else if(ans!=1)
				cout<<ans;
				cout<<"x";
			}
			work(k1,k2);
			if(abs(k2)%abs(k1)!=0) cout<<"y="<<k1<<"/"<<k2<<"x";
			int t=y-(x*k1/k2);
			if(t>0)
			cout<<"+"<<t<<endl;
			else cout<<"t"<<endl;
		}
	}
	return 0;
}

信息

递交者
类型
递交
题目
数学弱智题 T3
题目数据
下载
语言
C++
递交时间
2017-09-22 20:38:22
评测时间
2017-09-22 20:38:22
评测机
分数
0
总耗时
41ms
峰值内存
464.0 KiB