uva12894 Perfect Flag

uva12894

uDebug12894

关于孟加拉国国旗的题目,都是入门题,我印象中已经不下3题了。只能说,出题人比较爱国,喜欢向全世界的题友宣传普及本国的国旗。

python版本AC代码

testcase = int(input())
while testcase > 0:
	testcase -= 1
	p = list(map(int,input().split()))
	length = p[2] - p[0]
	width = p[3] - p[1]
	rlength = p[4] - p[0]
	rheight = p[5] - p[1]
	if length*3 == width*5 and length == p[6]*5 and rlength*20 == length*9 and rheight*2 == width :
		print("YES")
	else:
		print("NO")

C++版本AC代码

#include <iostream>
#include<cstdio>
using namespace std;

//#define ZANGFONG

int main()
{
    #ifdef ZANGFONG
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif // ZANGFONG

    int testcase;
    int x0,x1,y0,y1,cx,cy,r;
    int length,width,rheight,rlength;
    scanf("%d\n",&testcase);
    while(testcase--)
    {
        scanf("%d %d %d %d %d %d %d\n",&x0,&y0,&x1,&y1,&cx,&cy,&r);
        length = x1 - x0;
        width = y1 - y0;
        rlength = cx - x0;
        rheight = cy - y0;
        if(length*3 == width*5 && length == r*5 && rlength*20 == length*9 && rheight*2 == width) printf("YES\n");
        else printf("NO\n");

    }


    return 0;
}

猜你喜欢

转载自blog.csdn.net/zangfong/article/details/84581533