Search found 98 matches

by hamedv
Fri Sep 05, 2008 8:13 pm
Forum: Volume 108 (10800-10899)
Topic: 10816 - Travel in Desert
Replies: 49
Views: 22388

Re: 10816 - Travel in Desert

Hi My Code Gives write answer too all test cases that i have tested. but it gives run time error on some test cases. I tries to find the reason but i couldn't. please help me. i use 2 Floyd-Warshal s to solve it #include <algorithm> #include <iostream> #include <cstdio> #include <vector> using names...
by hamedv
Sat Aug 09, 2008 5:20 am
Forum: Volume 114 (11400-11499)
Topic: 11480 - Jimmy's Balls
Replies: 12
Views: 5606

Re: 11480 - Jimmy's Balls

i think the answer for n is round((n-3)^2/12)
if it's spoiler tell me to delete it?
by hamedv
Mon Aug 04, 2008 6:25 pm
Forum: Volume 114 (11400-11499)
Topic: 11475 - Extend to Palindrome
Replies: 32
Views: 13885

Re: 11475 - Extend to Palindromes

@baodog: Your code prints an extra unprintable character at the end of each line on my machine. But it looks otherwise ok. @hamedv: I'm curious about the O(n^2) DP you mentioned. The simple brute force way of solving this problem is also O(n^2). Could you please post an outline of your idea? I mean...
by hamedv
Mon Aug 04, 2008 6:20 pm
Forum: Volume 114 (11400-11499)
Topic: 11472 - Beautiful Numbers
Replies: 13
Views: 2937

Re: 11472 - Beautiful Numbers

I keep track of used numbers so far a the first dimension of an array. The other 2 dimensions are length and the last digit. For example 5 (101) means that I used numbers (0 and 2). When I find answers for each length I iterate through (111) values for each length and every digit to the left of the...
by hamedv
Mon Aug 04, 2008 5:19 pm
Forum: Volume 114 (11400-11499)
Topic: 11472 - Beautiful Numbers
Replies: 13
Views: 2937

Re: 11472 - Beautiful Numbers

Try these:

input:

Code: Select all

1
5 100
correct output:

Code: Select all

778091614
replace this line

Code: Select all

tabl[i][j]+=fun(i,j,k)
by this:

Code: Select all

tabl[i][j]=(tabl[i][j]+fun(i,j,k))%1000000007;
by hamedv
Mon Aug 04, 2008 8:30 am
Forum: Volume 114 (11400-11499)
Topic: 11472 - Beautiful Numbers
Replies: 13
Views: 2937

Re: 11472 - Beautiful Numbers

if (LASTDIGIT = 0 ans DIGITS = 1) ----------- mydpfunction(BASE, DIGITS, LASTDIGIT) = 0; IMHO the problem may be here. Don't assume, that the number 0 can't be used in DIGITS > 1. Since the number 10 is produced by adding 1 to zero. Once you have found the answer of a particular length. You can ite...
by hamedv
Sun Aug 03, 2008 8:39 pm
Forum: Volume 114 (11400-11499)
Topic: 11472 - Beautiful Numbers
Replies: 13
Views: 2937

Re: 11472 - Beautiful Numbers

yes you are right but can you tell me why i'm getting WA: mydpfunction(BASE, DIGITS, LASTDIGIT) = number of the beautiful numbers in base BASE which have DIGITS digits and their last digit is LASTDIGIT. if (LASTDIGIT = 0 and DIGITS = 1) ----------- mydpfunction(BASE, DIGITS, LASTDIGIT) = 0; if (DIGI...
by hamedv
Sun Aug 03, 2008 6:23 pm
Forum: Volume 114 (11400-11499)
Topic: 11475 - Extend to Palindrome
Replies: 32
Views: 13885

Re: 11475 - Extend to Palindromes

Yes, i don't know too

There were problems like this an i solved them using DP, because the input size was less than 1000 but in this problem it's so huge.
by hamedv
Sun Aug 03, 2008 6:19 pm
Forum: Volume 114 (11400-11499)
Topic: 11472 - Beautiful Numbers
Replies: 13
Views: 2937

11472 - Beautiful Numbers

i think it's a simple DP problem but i'm getting WA :( here is my code: #include <iostream> using namespace std; int main() { long long dp[11][101][10]; memset(dp, 0, sizeof dp); for (int i = 0; i < 11; i++) for (int j = 0; j < 10; j++) if (j) dp[i][1][j] = 1; else dp[i][1][j] = 0; for (int base = 2...
by hamedv
Sun Aug 03, 2008 8:49 am
Forum: Bugs and suggestions
Topic: 724 - Reverse
Replies: 3
Views: 1506

Re: 724 - Reverse

but i think the correct code is this:

Code: Select all

Code deleted by moderator.
by hamedv
Sun Aug 03, 2008 8:46 am
Forum: Bugs and suggestions
Topic: 724 - Reverse
Replies: 3
Views: 1506

Re: 724 - Reverse

Yeah i submited this code and got ac !!!
main(){}
by hamedv
Wed Jun 25, 2008 10:37 am
Forum: Volume 105 (10500-10599)
Topic: 10583 - Ubiquitous Religions
Replies: 33
Views: 14727

Re: 10583 - Ubiquitous Religions

Hi I'm getting WA but i don't know why does my code fail? I have checked it with many I/O from this site: http://uvatoolkit.com/ Please give me an input that my code gives wrong answer to it? #include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include <sstream> #include <...
by hamedv
Fri Apr 18, 2008 10:45 am
Forum: Volume 104 (10400-10499)
Topic: 10483 - The Sum Equals the Product
Replies: 21
Views: 10946

Re: 10483 - Why WA ???

Hi
I don't know why my code produces 352 triples. It also produced 352 triples after I changed my code as you said in previous posts. Please tell me which triples am i missing?
Here is my code:

Code: Select all

Thank you, Jan
by hamedv
Sat Jan 26, 2008 12:14 pm
Forum: Volume 113 (11300-11399)
Topic: 11392 - Binary*3 Type Multiple
Replies: 14
Views: 4945

if a number is a multiple of 2 it's first digit must be 0 or 2 or 4 or 6 or 8.
and if a number is a multiple of 5 it's first digit must be 0 or 5.
due this a number which is like this "11..11" is not a multiple of 2 or 5.
by hamedv
Sat Jan 19, 2008 1:53 pm
Forum: Volume 113 (11300-11399)
Topic: 11392 - Binary*3 Type Multiple
Replies: 14
Views: 4945

problem 10127 is another version of this problem. you can code it in less than 15 lines. in this problem numbers can be multiple of 2 or 5 because you can add zeros to the end of your number.

Go to advanced search