[ACM] 3625 Rounders

I just finished 3625 Rounders problem

I got run time error issue.

I have no idea where do i fix for this issue(run time error)

but my code perfectly work in my program environment.

it only not work for ACM online judge

please tell me what is run time error in this case

For a given number, if greater than ten, round it to 
the nearest ten, then (if that result is greater than 100)
 take the result and round it to the nearest hundred, then 
(if that result is greater than 1000) take that number and 
round it to the nearest thousand, and so on ...

Input 

Input to this problem will begin with a line containing 
a single integer n indicating the number of integers to 
round. The next n lines each contain a single integer x (0x99999999).

Output 

For each integer in the input, display the rounded integer on its own line.


Note: Round up on fives.

Sample Input 

9 
15 
14 
4 
5 
99 
12345678 
44444445 
1445 
446
Sample Output 

20 
10 
4 
5 
100 
10000000 
50000000 
2000 
500
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <iostream>
#include <vector>
using namespace std;


int jegop(int a, int b)

{
    
	int i,c;
    
	c=a;
    
    if( b ==0 ) return 1;
	for( i = 0 ; i < b - 1 ; i++ ){
        
		c = c * a;
        
	}
    
	return c;
    
}





int main (int argc, const char * argv[])
{
    int num =0;
    int n;
    int x= 999999999;
    
    int test;
    cin >> n;
    
   
    for( int i=0 ; i < n ; i++){
         cin >> x;
         num=0;
        while( (jegop(10,num) < x) && x <= 999999999){
            //cout << "loading..."<<endl;
            num++;
        
        }
        if ( num ==0 )  {
            //cout <<"1->"<<num<<endl;
            cout << x <<endl;
        }
        
    
        if( num != 0 && x >100 ) {
            //cout <<"2->"<<num<<endl;
            //cout <<"here "  << num <<endl;
            for( int i= int(jegop(10,num)/x) ; i > 0 ; i--){
                //cout <<"first i->"<< i <<endl;
                
                if( (jegop(10,num) % i)== 0 && (jegop(10,num)/i)% (i-1) == 0   ) {
                    //cout <<"important->" <<jegop(10,num) <<endl;
                    int k=0;
                // cout << " num->" <<num<<endl;
                    int numtemp= num-3;
                    for( int y=numtemp ; y>=0 ; y--){
                       //cout << "Y:  "<< y <<endl; 
                        k += jegop(10,y) * 5;
                        //cout <<"result" << jegop(10,0) <<endl;
                        
                    }
                    
                    //cout <<"k->"<< k <<endl;
                   // cout <<" i->"<<i <<endl;
                    //if((jegop(10,num)/i)-x   < ((jegop(10,num-1)/2)-k)) {
                    if(x-((x/jegop(10,num-1))*jegop(10,num-1))       < ((jegop(10,num-1)/2)-k)) {
                      //  cout << " first loop..." <<endl;
                        cout << (jegop(10,num)/i)/2-(((jegop(10,num)/i)/2) % jegop(10,num-1))<<endl;
                        break;
                    }
                    else {
                        ///cout << "second loop.." <<endl;    
                        cout << (jegop(10,num) /i)   -  (  (jegop(10,num) /i) % jegop(10,num-1))  <<endl ; 
                        break;
                    }
                }
            }
            
        }else if(num != 0 && x <100 && x> 9  && x !=0){
            if( x/ 10 >=4 && x%10 >=5) {
               // cout <<"third"<<endl   ; 
            cout << ((x/10)+1)*10<<endl;
            }else{
                
                
                //cout << "fourth..."<<endl;
                
                if( x%10 >=5 ) cout << (x/10)*10*2<<endl;
                else{cout << (x/10)*10<<endl;}
            }
            
        }else if(x <10 && x !=0 ) cout << x <<endl;
        
    }
    

}
Last edited on
1
2
3
4
5
6
7
//line 59
if( 
   (jegop(10,num) % i)== 0
   && 
      (jegop(10,num)/i) 
      % (i-1) //division by 0
   == 0   )
Last edited on
Topic archived. No new replies allowed.