ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1118. Nontrivial Numbers

What can be the reason of WA 11? I'll be glad if you give some tests.
Posted by D4nick 31 Mar 2020 08:11
#include <iostream>
using namespace std;
int main() {
    long long i, j, iDel; long long biggestV = 9999999, biggestDel = 9999999;
    cin >> i >> j;
    if (i == 1) {
        cout << 1;
        return 0;
    }
    else if (i == j) {
        cout << i;
        return 0;
    }
    else if (i + 1 == j) {
        cout << (j % 2 != 0 ? j : i);
        return 0;
    }
    for (long long iV = j % 2 != 0 ? j : j-1; iV >= i; iV -= 2) {
        for (iDel = j / 3 + 1; iDel >= 1; iDel--) {
            if (iV%iDel == 0) {
                if (iDel < biggestDel) {
                    biggestDel = iDel;
                    biggestV = iV;
                }
                break;
            }
        }
        if (iDel == 1) {
            cout << iV;
            return 0;
        }
    }
    cout << biggestV;
}
Re: What can be the reason of WA 11? I'll be glad if you give some tests.
Posted by ToadMonster 31 Mar 2020 14:10
In the main cycle you doesn't compare trivialities, you search the smallest biggest divisor in the weird range instead. Could you please show the mathematical proof of your main cycle?

Edited by author 31.03.2020 14:11

Edited by author 31.03.2020 14:12
Re: What can be the reason of WA 11? I'll be glad if you give some tests.
Posted by wiwi 19 Nov 2020 04:35
Hi.Did you solve this problem?