• Special Judge Ⅱ


    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;
    }
    彼时当年少,莫负好时光。
  • 相关阅读:
    hihocoder 1038
    hihocoder 1039
    poj 2774
    bzoj 4690&&4602
    poj 2417
    STL
    poj 1026
    poj 1064
    poj 1861(prim)
    poj 1129
  • 原文地址:https://www.cnblogs.com/l609929321/p/6959200.html
Copyright © 2020-2023  润新知