码迷,mamicode.com
首页 > 其他好文 > 详细

Special Judge Ⅱ

时间:2017-06-07 22:27:58      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:stream   acm   blog   程序设计   判断   ble   spec   wro   nan   

Problem Description

Q:什么是 Special Judge,Special Judge 的题目有什么不同?

A:一个题目可以接受多种正确答案,即有多组解的时候,题目就必须被 Special Judge。Special Judge 程序使用输入数据和一些其他信息来判答程序的输出,并将判答结果返回。

NaYe 最近遇到了一个题,要求输出三个数,第三个数为前两个数的和,三个数都是素数,且前两个数小于 500000。他只需要输出任意一组符合要求的答案即认为是 Accepted。现在需要你做的是判断 NaYe 的程序运行结果对不对。

Input

输入数据有多组(数据组数不超过 100),到 EOF 结束。

对于每组数据,输入 a, b, c 三个整数。含义同题目描述。

a, b, c 均在 int 范围内。

Output

对于每组数据,如果 NaYe 的程序正确输出 “Accepted”,否则输出 “Wrong Answer”(输出不包括引号)。

Example Input

1 1 1
2 3 5
3 5 8

Example Output

Wrong Answer
Accepted
Wrong Answer

Hint

 

Author

「“师创杯”山东理工大学第九届ACM程序设计竞赛 热身赛」MLE_kenan
注意判断素数时还要考虑判断的数是否为0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
int f(int n)
{
    if(n==2)
        return 1;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    int a,b,c;
    while(cin >> a >> b >> c)
    {
        if( c==a+b && f(c) && a<500000 && b<500000 && f(a) && f(b) && a!=0 && b!=0)//考虑0的特殊情况
            cout << "Accepted" << endl;
        else cout << "Wrong Answer" << endl;
    }
    return 0;
}

 

Special Judge Ⅱ

标签:stream   acm   blog   程序设计   判断   ble   spec   wro   nan   

原文地址:http://www.cnblogs.com/l609929321/p/6959200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!