ZOJ 3488 Conic Section

12 篇文章 0 订阅

题意:给出一个多项式的每一项的系数,求出这个多项式表示怎样的曲线

链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3488

思路:找出每一个多项式的特点,if判断即可。当a=0,c=1或a=1,c=0时为抛物线,当a,c异号时为双曲线,当a==c==0时为圆,若不符合以上情况,为椭圆。

注意点:输入的是实型,不是整型


以下为AC代码:

Run IDSubmit TimeJudge StatusProblem IDLanguageRun Time(ms)Run Memory(KB)User Name
39687942015-05-24 23:24:42Accepted 3488C++0x10272luminus
#include <algorithm>
#include <iostream>
#include <climits>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
//#include <unordered_map>
//#include <unordered_set>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define RS(s) scanf ( "%s", s )
#define RDI(a) scanf ( "%d", &a )
#define RDII(a, b) scanf ( "%d%d", &a, &b )
#define RDIII(a, b, c) scanf ( "%d%d%d", &a, &b, &c )
#define PL() printf ( "\n" )
#define PI(a) printf ( "%d", a )
#define PIL(a) printf ( "%d\n", a )
#define PSL(s) printf ( "%s\n", s )
#define PII(a,b) printf ( "%d %d", a, b )
#define PIIL(a,b) printf ( "%d %d\n", a, b )
#define PIII(a,b,c) printf ( "%d %d %d", a, b, c )
#define PIIIL(a,b,c) printf ( "%d %d %d\n", a, b, c )
#define rep(i,m,n) for ( int i = m; i <  n; i ++ )
#define REP(i,m,n) for ( int i = m; i <= n; i ++ )
#define dep(i,m,n) for ( int i = m; i >  n; i -- )
#define DEP(i,m,n) for ( int i = m; i >= n; i -- )
#define repi(i,m,n,k) for ( int i = m; i <  n; i += k )
#define REPI(i,m,n,k) for ( int i = m; i <= n; i += k )
#define depi(i,m,n,k) for ( int i = m; i >  n; i += k )
#define DEPI(i,m,n,k) for ( int i = m; i >= n; i -= k )
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
//#pragma comment ( linker, "/STACK:1024000000,1024000000" )
using namespace std;
const double pi = acos(-1.0);
template <class T>
inline bool RD ( T &ret )
{
    char c;
    int sgn;
    if ( c = getchar(), c ==EOF )return 0; //EOF
    while ( c != '-' && ( c < '0' || c > '9' ) ) c = getchar();
    sgn = ( c == '-' ) ? -1 : 1;
    ret = ( c == '-' ) ? 0 : ( c - '0' );
    while ( c = getchar() , c >= '0' && c <= '9' ) ret = ret * 10 + ( c - '0' );
    ret *= sgn;
    return 1;
}
inline void PD ( int x )
{
    if ( x > 9 ) PD ( x / 10 );
    putchar ( x % 10 + '0' );
}
const double eps = 1e-6;
const int dir[4][2] = { 1,0, -1,0, 0,1, 0,-1 };
struct node{
    int x, y, cnt;
    node(){}
    node( int _x, int _y ) : x(_x), y(_y) {}
    node( int _x, int _y, int _cnt ) : x(_x), y(_y), cnt(_cnt) {}
};
struct edge{
    int to, wei;
    edge(){}
    edge( int _to, int _wei ) : to(_to), wei(_wei) {}
};
bool cmp ( double a, double b )
{
	if ( a - b > -eps && a - b < eps ){
		return true;
	}
	else {
		return false;
	}
}
int main()
{
	int T;
	RDI ( T );
	while ( T -- ){
		double a, b, c, d, e, f;
		scanf ( "%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f );//RDIII ( a, b, c );
		//RDIII ( d, e, f );
		if ( ( cmp ( a, 0 ) == 0 && cmp ( c, 0.0 ) == 1 ) || ( cmp ( a, 0.0 ) == 1 && cmp ( c, 0.0 ) == 0 ) ){
			printf ( "parabola\n" );
		}
		else if ( a * c < 0 ){
			printf ( "hyperbola\n" );
		}
		else if ( cmp ( a, c ) == 1 && cmp ( a, 0 ) == 0 ){
			printf ( "circle\n" );
		}
		else{
			printf ( "ellipse\n" );
		}
	}
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值