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 1023. Buttons

WHY CE?????
Posted by discouraged one 29 Jan 2003 15:46
#include <iostream.h>
#include <math.h>

int main(void)
{
    int K;
    int ind = 1;
    int L = 0;

    cin >> K;

    if( !(K % 2) )
    {
        while( (!(K % 2)) && (K > 4) )
            K /= 2;

        L = K - 1;
        ind = 0;
    };

    for(int i = 3 ; ( i <= ceil( sqrt(K) ) ) && ind ; ++i)
    {
        if( !(K % i) )
        {
            L = i - 1;
            ind = 0;
        };
    };

    if( (K != 1) && (L == 0) )
        L = K - 1;
    cout << L;

    return 0;
};
//I compiled it under bc 3.0, vc 7.0, vc 6.0
//Please HELP
Re: WHY CE?????
Posted by Blue Soply 1 Feb 2003 15:47
   My program got CE at the first,but when I changed sqrt(K) to
sqrt((double)K),it got AC.Maybe you can have a try,good luck&#1032;&#1038;