#include<iostream>
int main()
{
int n ;
while( std::cin >> n )
{
if( n == 0 )
{
std::cout << "0\n" ;
continue ;
}
int arr[10000] ;
int a = 0 , j = 0 , x = 1 , y = 1 ;
if( n < 0 )
{
a = 1 ;
n *= -1 ;
}
for(int i = 2 ; i <= n ; i++)
while( n % i == 0 )
{
arr[j] = i ;
n /= i ;
j++ ;
}
for(int i = 0 ; i < j ; i++)
{
if( arr[i] == arr[ i + 1 ] )
{
x *= arr[i] ;
i++ ;
}
else
y *= arr[i] ;
}
if( x == 1 && y == 1 )
std::cout << "1" ;
else if( x == 1 && y > 1 )
std::cout << "_/" << y ;
else if( x > 1 && y == 1 )
std::cout << x ;
else if( x > 1 && y > 1 )
std::cout << x << "_/" << y ;
if( a == 1 )
std::cout << "i\n" ;
else
std::cout << "\n" ;
}
return 0 ;
}
第 1 測資點(100%): WA (line:183)
答案不正確
您的答案為: 888i 正確答案為: 24_/37i
我自己輸入-21312
輸出是24_/37i
交上去就變成888i
who can tell me why ?