347 - Run
Moderator: Board moderators
-
- New poster
- Posts: 1
- Joined: Wed Dec 24, 2003 12:03 pm
please help me
My code is TLE. I can realize that for input 9999998 my code is TLE.
Can anyone please say me what is the output for it.
Can anyone please say me what is the output for it.
Re: please help me
I didn't get accepted, but I think the bigger runaround number is 9682415. Am I correct??
I think you are correct, i.e. the biggest number is 9682415.
I generated 448 runaround numbers in total.
I generated 448 runaround numbers in total.
:: HanWorks ::
problem 347 WAAAA!!!!!!!
i generate all the 448 run around numbers.
then i just print the number greater or equal to input;
all output seems ok.
but i m getting WAAAAAA!!!!!!!!!!!
someone please help!
i m going crazy.........................
the biggest number is 96.... something like this.
what will be the output for .........
9999999 ???????
please help me.............
then i just print the number greater or equal to input;
all output seems ok.
but i m getting WAAAAAA!!!!!!!!!!!
someone please help!
i m going crazy.........................
the biggest number is 96.... something like this.
what will be the output for .........
9999999 ???????
please help me.............
/* Sorry For Nothing */
Re: problem 347 WAAAA!!!!!!!
Well, I don't think there is input greater than the largeest run-around number. Problem maybe somewhere else. Check your output format.Sakib wrote:what will be the output for .........
9999999 ???????
Thanks for help.
i dont understand what could be wrong.
here is my code :
please check it to see the output format is correct.
tell me what is wrong..........
i dont understand what could be wrong.
here is my code :
Code: Select all
Cut After ACC.
tell me what is wrong..........
Last edited by Sakib on Tue Nov 15, 2005 9:18 pm, edited 1 time in total.
/* Sorry For Nothing */
Ups !!!!!!!
That was a stupid mistake.
ACC now.
Many Many thanks to u for help.
My code was working well with sample input and output in my PC without initializing the arr[] in isDiff().
But really that mistake was stupid. i should not do that mistake.
Anyway thanks again mamun.
That was a stupid mistake.
ACC now.
Many Many thanks to u for help.
My code was working well with sample input and output in my PC without initializing the arr[] in isDiff().
But really that mistake was stupid. i should not do that mistake.
Anyway thanks again mamun.
/* Sorry For Nothing */
-
- Learning poster
- Posts: 91
- Joined: Tue May 31, 2005 2:01 pm
- Location: Russia
347 Run, Run, Runaround Numbers
Hi all! I am interested in who how solved it? I did precompute some values of the runaround numbers at my computer and insert them to a programm as an array. If an input number is greater than the lowest array's element and is lower than the biggest array's element then i find answer in the array. Otherwise i check all the value that bigger or equal to input number until i found runaround number.
I want to know is there a more effective algorithm?
I want to know is there a more effective algorithm?
Re: 347 Run, Run, Runaround Numbers
Any Special Cases Please
There is my code
Thanks
There is my code
Code: Select all
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string Number;
bool Visited[10];
bool allVisited()
{
for(int i = 0; i < Number.length(); i ++)
if(Visited[i] == false)
return false;
return true;
}
bool isRunaroundNumber(int Index)
{
if(Index == 0 && allVisited())
{
return true;
}
if(!Visited[Index])
{
Visited[Index] = true;
int Next = (Index + Number[Index] - 48);
if(Next >= Number.length())
Next %= Number.length();
isRunaroundNumber(Next);
}
}
void addOne(string& Number)
{
for(int i = 0; i < Number.length(); i ++)
if(Number[i] == '0')
Number[i] ++;
reverse(Number.begin(), Number.end());
int Index = 0;
Number[Index] += 1;
while(Number[Index] > '9')
{
Number[Index ++] -= 9;
if(Index == Number.length())
Number += "1";
else
Number[Index] += 1;
}
reverse(Number.begin(), Number.end());
}
bool DigitsAreUnique(string& Number)
{
for(int i = 0; i < Number.length(); i ++)
{
for(int j = i + 1; j < Number.length(); j ++)
{
if(Number[i] == Number[j])
return false;
}
}
return true;
}
void removeLeadingZeros(string& Number)
{
string Temp = "";
bool First = true;
for(int i = 0; i < Number.length(); i ++)
{
if(Number[i] != '0' && First)
First = false;
if(!First)
Temp += Number[i];
}
Number = Temp;
}
int main()
{
freopen("ACM.in", "r", stdin);
for(int Case = 1; getline(cin, Number) && Number != "0"; Case++)
{
removeLeadingZeros(Number);
fill(Visited, Visited + 10, false);
while(!DigitsAreUnique(Number) || !isRunaroundNumber(0))
{
addOne(Number);
fill(Visited, Visited + 10, false);
}
cout << "Case " << Case << ": " << Number << endl;
}
return 0;
}
-
- New poster
- Posts: 6
- Joined: Sat Mar 06, 2010 8:30 am
347 Java Runtime Error (Again?!?!)
Previously I posted a topic in this Volume III board about getting java runtime error on problem 343
but I didn't get any reply or solution
Then I moved on to another problem which is problem 347 and I still got runtime error (again) using java
Here is my code
Please anyone,
I desperately need a solution on this error
I know probably using C/C++ is one of the solution but I don't know C/C++ programming well
Therefore I need to know how to submit source code in java programming in UVa OnlineJudge
Any solution will be very appreciated
Thx.
but I didn't get any reply or solution
Then I moved on to another problem which is problem 347 and I still got runtime error (again) using java
Here is my code
Code: Select all
// @JUDGE_ID: 250890 374 Java "Big Mod"
import java.io.BufferedReader;
//import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
class BigModMain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Scanner in = new Scanner(new FileInputStream(new File("input")));
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
BigInteger b = BigInteger.ZERO;
BigInteger p = BigInteger.ZERO;
BigInteger m = BigInteger.ZERO;
while (in.hasNext()) {
b = in.nextBigInteger();
p = in.nextBigInteger();
m = in.nextBigInteger();
System.out.println(b.modPow(p, m));
}
in.close();
return;
}
}
I desperately need a solution on this error
I know probably using C/C++ is one of the solution but I don't know C/C++ programming well
Therefore I need to know how to submit source code in java programming in UVa OnlineJudge
Any solution will be very appreciated
Thx.
Re: problem 347 WAAAA!!!!!!!
well I don't know what happened on my code
I always got WA
but I can't find out where my problem is,format? Or something I miss?
I don't know
pls someone for help!!!!!
I always got WA
but I can't find out where my problem is,format? Or something I miss?
I don't know
pls someone for help!!!!!
Code: Select all
delete after AC
Last edited by bobSHIH on Thu Feb 20, 2014 9:46 am, edited 1 time in total.