Общий форумTry this: 5 2 3 4 5 6 7 2 8 9 10 The answer is 4. This is Test 2: 7 1 90 91 125 129 200 3 130 140 150 160 162 201 202 The answer is 5. try this: 4 1 5 6 7 2 3 4 5 resault is 3. Thanks for this examples :) Edited by author 18.03.2015 19:57 Edited by author 18.03.2015 19:57 10 .......... #......#.. ...#...... ###..#...# ...#..##.. ......##.. ....#..### ...#..#.#. ..#####... ....#..... Answer 864 20 ..........#......#.. ...#......###..#...# ...#..##........##.. ....#..###...#..#.#. ..#####.......#..... ..#..#.#..#.###.##.. ...#.......#..#..... ..#.##...#...#.####. ..##.#....#....##... ...#..#.....###...#. #...###.##...#.##.#. .......#..#..##..... ...#...##........... .......###....#.###. #..###.#.#.#.......# .....#.##..#.#.####. #....##..#.#..#...#. ....#..#.###...#.##. .#.......#....#.#.## ......#.....#....... Answer 3222 33 ..........#......#.....#......### ..#...#...#..##........##......#. .###...#..#.#...#####.......#.... ...#..#.#..#.###.##.....#.......# ..#.......#.##...#...#.####...##. #....#....##......#..#.....###... #.#...###.##...#.##.#........#..# ..##........#...##............... ...###....#.###.#..###.#.#.#..... ..#.....#.##..#.#.####.#....##..# .#..#...#.....#..#.###...#.##..#. ......#.#..#.#.##......##....##.. .#.#.#..#.####.#..##.#..##....#.# ..#.#..#...#...#....#..#.....#... #....##....##.....#....#.#..#...# ..####...#..##.#..#......#.....#. ..#.####..#...#####...#....#.#.#. .......###.##.....#....##.#.#.#.. ..#.....#.##.#...#..#....#.#.#... #..##.#...#.......#.......#...#.. #...#..#.##.#.......#.##..####... .#....#..#####......#.#.###....#. ..#.#.#....#.#.#..##..#....#..##. .#..##...#.###..#.......###.#..## .#.#.....#..............###...#.. ..##...####.#.#..##.#.#....#...#. .....##...........#.#....#....##. ..##..#.####...#.##.....##.#..... .....#...........##.#.##.#.#...#. .#........#......##.....#..###.## ....##...#.#.#.#.######...#...#.. #...###..#....#.##.#...#.#......# .........##..##.##.........#..... Answer 8676 9 ..##.#### #.......# .#.##.##. ##..#.#.# ...#..#.. #......#. .....#..# #####..#. #.###.... Answer 576 Edited by author 18.03.2015 14:06 I think: if n = 1 => 14 if n = 2 => 16 (+1040, 2080) if n > 2 => 17 (+10...080...0) Is not it??? Sorry for my worse English. For example, 1144 and 2288 are interesting too. n = 1 n = 2 n = 3 n = 4 ..... ..... ..... n = 16 i think this tests will be useful for u plz move it up to the easier places ??? Edited by author 18.03.2015 00:12 In the problem set there is nothing told about how can user stop to input numbers. i think you should use while(cin>> ){ } getting input from user will end when he insert invalid value like characters #include <iostream> #include <conio.h> using namespace std; void find(int j, int i, int &k1,int &k2) { if (j==i+1) return; else { int buf = k1; k1 = k1 + k2; k2 = buf; find(j-1,i,k1,k2); } } int main() { long long Fi, Fj, f1,f2, f3; int i,j,n; cin>>i>>Fi>>j>>Fj>>n; if (j==n) {cout<<Fj<<endl; return 0;} if (i==n) {cout<<Fi<<endl; return 0;} if (i<j) { int buf = i; i = j; j = buf; buf = Fi; Fi = Fj; Fj = buf; } int k1 = 1, k2 = 1; f1 = Fj; if (i!=j+1) { find(i-1,j,k1,k2); f2 = (Fi - k2*Fj)/k1; } else f2 = Fi;
int lim; if (j<0) lim = n - j -1; else if (j == 0 ) lim = n; else lim = n - j +1; for (int count = j +1; count < lim; count++) { f3 = f1 + f2; f1 = f2; f2 = f3; } cout<<f3<<endl; return 0; } I think I have correct solution.(DP) but i got WA#11. pls give some tests. Edited by author 29.01.2007 21:21 [((((((((((((((((((((()))))))))]))))))))))))](((((((((((((((((((((((((((]))))))))))))))))))))))))))) AC answer [((((((((((((((((((((()))))))))[]))))))))))))]((((((((((((((((((((((((((([]))))))))))))))))))))))))))) Edited by author 30.01.2007 00:46 Thank you, Anton! Your test allows to debug and avoid WA as well as TLE. using System.IO; using System; class Program { static void Main() { int size = Int32.Parse(Console.ReadLine()); int[,] arr=new int[size,size]; int count=1; for(int x=size;x>=0;x--) { int y=0; int xx=x; bool exc=false; while(!exc) { try { arr[xx,y]=count; count++; xx++; y++; } catch { exc=true; break; } } }
for(int y=1;y<=size-1;y++) { int x=0; int yy=y; bool exc=false; while(!exc) { try { arr[x,yy]=count; count++; x++; yy++; } catch { exc=true; break; } } }
for(int x=0;x<size;x++) { for(int y=0;y<size;y++) { Console.Write(arr[y,x]+" "); } Console.WriteLine(); }
} } Can Anyone give me some hints for test 3, I've been working on it for 3 days but still got test 3. I give the right answers for all the tests on forum Try this test 1 1 499 999 999 answer is 3. 499 999 999 = 691*723589 The spaces shouldn't be there in the last number by the way. import java.io.BufferedReader; import java.io.InputStreamReader; public class AB { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int a = Integer.parseInt(reader.readLine()); int b = Integer.parseInt(reader.readLine()); System.out.println(a+b); } } У меня такое же решение. Тоже не принимает... Numbers are located at the same line. So, first call of readLine() give you "a b", and second - null. I got WA at #4 by using int type but got AC by using long long I don't understand... I think the max of date is 1e6(maybe n=1e4 and every ti=100, in this way the sum time is 1e6 and it's max) Am I wrong? Who can tell me plz Edited by author 15.03.2015 21:47 Здравствуйте, уважаемые администраторы! Я очень давно изучаю язык Action Script принадлежащий компании Adobe. У меня созрел такой вопрос: Вы добавите поддержку языков Action Script или отодвините всех программистов этой отрасли? Can someone tell me the test case 2 please. I am new in here and I need some help with 1017. Staircases. Edited by author 14.03.2015 15:34 Edited by author 14.03.2015 15:34 What may it be? i've try any test i can think and any test in other discussins,but still WA #11. I tested : ------- WHAT ARE YOU DOING? - I AM EATING. - really? -Yes,(new line) REALLY! - ok, i KNOW. i TRUST YOU. ------- and my program output : ------- What are you doing? - I am eating. - Really? -Yes, really! - Ok, i know. I trust you. ------- I don't know what's wrong, help, please. It must be "i trust you." not "I trust you" For my first try I wrote this: def sum_of_digits(n) sum = 0 while (n > 0) sum += n % 10 n /= 10 end sum end num_digits = gets.chomp.to_i exponent = num_digits/2 divisor = 10**exponent limit = (10**num_digits) - 1 total = 0 0.upto(limit) do |cur| upper = cur / divisor lower = cur % divisor total += 1 if sum_of_digits(upper) == sum_of_digits(lower) end puts total # eof For 2, 4 and 6 digits it got the requisite answers of 10, 670, and 55252. There was a bit of a pause while it crunched away at the 6-digit case, though. For 8 digits it … well, I let it run and went to do something else. Then I had the bright idea to time it (on mac OS X, using the time command): 4816030 real 1m42.596s user 1m34.222s sys 0m1.837s The right answer, but the last time I checked, one minute anything was greater than two seconds. What to do? It’s pretty clear that calling sum_of_digits a bunch more times than necessary is the biggest problem. For try #2, I precomputed the sums and stuffed them into an array, and indexed the array in place of calling sum_of_digits in the main loop. Here’s the result: time ruby lucky.rb < t8.txt 4816030 real 0m19.176s user 0m18.017s sys 0m0.313s A better than 80% speedup. Most times I would kill for that, but I still need to lose 95% of the remaining run time. How to do it? I checked … initializing the array of sums takes virtually no time, even if I write out the entire array contents to a file. So the main loop is killing me, and unfortunately I need a dramatic change of algorithm but I don’t see one. So … 1. Recode in C or C++ 2. Hell if I know Taking option 1, I got Accepted, with run times around 1.1 seconds or so for 8 digits. It's a straightforward translation to C++, very brute force. Try this test: -1 -1 1 Answer: 0.00 0 0 Solved it with time of 0.5 sec and using "Trie" where I keep the name of each directory as a node. Write me novopashinwm@mail.ru |
|