Common Boarddeleted Edited by moderator 23.07.2022 20:36 Почему в случае 1 10 ответ 9 если 0 тоже число в котором не идут два подряд ноля? Просто 2 раза получил ВА, поменял на 9 и АС. N ≥ 2. Test "1 10" is incorrect; there is no such test in the test set. You are wrong. In case 1 10 you have exactly nine 1-digit numbers without two or more subsequent zeros. They are: 1,2,3,4,5,6,7,8 and 9. What do you mean? '0' is *also* a 1-digit number without two or more subsequent zeroes, no? Also, yay for necroposting! Calculate matrix with modulo 10^9 + 7 #include <bits/stdc++.h> using namespace std;
int const N = 123456; #define pi acos(-1.0) typedef long long ll;
int ar[N],xar[N],uses[N];
struct points { double x, y; int id; points() {} points(double x, double y) : x(x), y(y) {} } ;
double ang(const points &p){ double res = atan2(p.y, p.x); if(res < 0) res += 2.0 * pi; return res; }
struct cmp{ inline bool operator () (const points &p1, const points &p2){ double ang1 = ang(p1)*(180/pi), ang2 = ang(p2)*(180/pi); if(fabs(ang1 - ang2) < 1e-9){ ll d1 = (ll)p1.x * (ll)p1.x + (ll)p1.y * (ll)p1.y; ll d2 = (ll)p2.x * (ll)p2.x + (ll)p2.y * (ll)p2.y;
return d1 < d2; } return ang1 < ang2; } };
points pt[N];
int main() { int n; cin >> n; for(int i = 0; i < n; i++){ cin >> pt[i].x >> pt[i].y; pt[i].id = i+1; } sort(pt, pt+n, cmp()); cout<<pt[0].id<<" "<<pt[(n/2)].id<<endl;
return 0; } I know this is an old post. but for others' reference, we should use long long to avoid integer overflow. Sort the intervals by length. and from i=0 to no_of_intervals, mark the query numbers. Make sure that each query number is marked by only one interval. Edited by author 17.05.2022 11:32 What's the test for WA#9? Try 3 0 0 10 10 10 0 20 10 20 0 30 10 Answer 36 try a rectangle in the negative area Windows, linux, maxOS? Why I can't include <windows.h>? (Compilation error: No such file or directory) 3 4 1 100 1000 0 1 1 1000 0 100 0 1000 100 //answer 1 1 2 2 1 1 1000000000 //answer 1 5 6 525 0 171 0 872 673 0 843 0 0 0 0 0 277 0 202 0 0 0 0 733 957 65 96 637 566 0 0 0 441 //answer: 4 4 5 5 5 5 10 1 10 10 10 1 1 10 10 10 1 10 1 1 1 1 1 1 10 1 10 10 10 10 1 //answer: 2 2 1 1 1 1 1 10 100 90 80 70 60 50 40 30 20 10 //answer: 10 5 6 1 0 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 //answer: 2 2 3 3 3 2 2 3 2 3 1 1 1 1 3 //answer: 2 2 1 1 3 1 1 1 1 //answer: 1 1 1 You 3rd and 6th test cases are wrong. The fee should be positive. тест 1: n=9 k=2 тест 2: n=1 k=1 тест 3: n=10 k=1 тест 4: n=8 k=1 тест 5: n=10 k=2 тест 6: n=7 k=2 тест 7: n=1 k=2 тест 8: n=2 тест 9: n=10 k=5 тест 10: n=9 k=5 n=3,4,5,6 не встречается... тест 8 - к по условию не может быть меньше 1. В единственной строке сначала дано целое число n, 1 ≤ n ≤ 10, затем ровно один пробел, затем k восклицательных знаков, 1 ≤ k ≤ 20. про значение К в этом тесте не известно а какой ответ на 9 тест? 1) 50 Очень интересно а как вы эти тесты извлекли? Edited by author 10.02.2010 23:53 Какой ответ на тест 5? 945? Тест 8 - просто супер. Явная неучтенка. И сколько еще таких тестов? Просто офигенная постановка задачи. Edited by author 16.04.2011 19:50 Скажите,пожалуйста, какой должен быть ответ в тесте номер 8? Я уже пробовала,чтобы программа не пропускала такие варианты с помощью repeat, пробовала ставить в таком случае ответ 1, ответ 0, ответ - само число. Ничего не получается! Edited by author 29.07.2014 13:12 Тест 10: 9 !!!!! = 9(9-5)(9 mod 5) = 9*4*4 = 144 Почему вылазит неправильный ответ?! N mod K — это последний больший нуля элемент ряда N - XK. В данном случае этот элемент первый и он же последний, не нужно умножать на него два раза. Иными словами, мы вычитаем K от исходного числа, и умножаем на получившееся, и повторяем так до тех пор, пока получившееся число не станет нулём или меньше. Еще вопрос: 2 !!! = ? 2 или 4? и какие вводные 11-го теста? Меня очень интересует как в примере 9 !! получилось равным 945 если разбирать описание задачи то получим: n = 9 k = 2 n mod k = 1(есть остатое от деления) тогда получаем 9!! = 9*(9-2)*1 = n(n-k)(n mod k) = 9*7*1 = 63 Ну откуда 945 невкурю???? This problem is easily solving without any precalcing or info about tests. Not more than 15-20 lines of code. I did not ask about the problem of solving the problem. I asked about the correctness of my reasoning, I can not right in the calculation of 9 !! 9 !! i 1) n:=9*(9-2) 2)n:=63*(9-4) 3)n:=315*(9-6) 4)n:=945*(9-8) This is correctness of your reasoning. In my program test 5 is correct, but system writed, that wrong. Answer - 7680 In my program test 5 is correct, but system writed, that wrong. Answer - 7680 All manual tests ok. Test 5 is also in error. I do not understand this... import java.util.*; public class Factor { public static void main(String[] args){ Scanner put=new Scanner(System.in); int n,k,fac; String ffc; n=put.nextInt(); ffc=put.next(); k=ffc.length(); fac=n; for(int i=1;i<(n/k);i++){ fac=fac*(n-(i*k)); } if(n%k!=0)fac=fac*(n%k); else fac=fac*k; System.out.print(fac); } } Edited by author 29.10.2012 17:37используя гамма функцию можно в одну строчку :) Застрял в тесте 8: #include<stdio.h> #include<string.h> int main(){ int n, i, l; char k[20]; scanf("%d%s", &n, k); l = strlen(k); int result = n; i = n - l; do{ result = result * i; i = i - l; } while (i > n % l); if (n == 1) result = 1; printf("%d", result); return 0; } Edited by author 02.12.2017 02:41 Edited by author 02.12.2017 02:41 Edited by author 25.07.2014 12:47 9 !! = 9*(9-2)*(9-2*2)*(9-2*2*2)....*1=9*7*5*3*1=945 Answers for numbers from topic: 1. 945 2. 1 3. 3628800 4. 40320 5. 3840 6. 105 7. 1 8. 2 (if in this case k = 1) 9. 50 10. 36 Моё нестандартное решение :) import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class proga { public static void main(String[] args) throws IOException { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); String[] temp = sc.readLine().split(" "); int ch = Integer.parseInt(temp[0]); int len = temp[1].length(); int ost = ch%len; int result = ch; if(ost==0){ost+=len;} while(ch!=ost) { ch-=len; result*=ch; } System.out.println(result); } } а какой ответ на тест 5 ? what's the right answer for test 5 ? who knows ? can you give a hand pls тест 1: n=9 k=2 тест 2: n=1 k=1 тест 3: n=10 k=1 тест 4: n=8 k=1 тест 5: n=10 k=2 тест 6: n=7 k=2 тест 7: n=1 k=2 тест 8: n=2 тест 9: n=10 k=5 тест 10: n=9 k=5 n=3,4,5,6 не встречается... why wrong on test 5?? #include<iostream> //#include<string> using namespace std; int main() { int n; string s; cin>>n; cin>>s; int sum=n; int len = s.size(); //cout<<len<<endl; int i =1; while((n-i*len)>1) { sum*=(n-i*len); i++; } if(n%len!=0) cout<<(sum*(n%len))<<endl; else cout<<sum*len<<endl; return 0; } 8th test is 2 !! and the answer is 2 clarification if you are stuck. RedBlue Mana can be made from red or blue i.e C can use (remA + remB) after using A and B through X and Y respectively. Do count what you use from C when required. anybody, who knows where can be error! help! I'm also getting WA#7... and don't know why :'( if you will find you mistake, please, write it here! ok? and if i'll find my, i'll write it here too. size of ansver is greatest longint. Use int64. Thanks! After your post I managed to solve it. But, actually I was using int64, but... I've found out that if you write like this: ans:=x*y*z; where ans is int64 and x,y,z are integer you get WA After I wrote: ans:=x; ans:=ans*y; ans:=ans*z; I got Accepted. I think it happens because of calculation x*y*z is performed in integer and then converted to int64. Interesting... :-| Should have written in C. I guess I wouldn't have faced this if written in C. Edited by author 19.02.2007 00:56 Should have written in C. I guess I wouldn't have faced this if written in C. It's common feature of all compilers I know. I guess, C would not help you also :) Can anyone pls explain to me the sample output on test 3 I had wa7 too. be carefull printf("%lld\n",ans) IS WRONG! printf("%I64d\n",ans) is OK for MSVS2005 it's no matter, but not for Timus compiler In test #7 the second line (instructions' string) is empty! the problem could be reading the line with 10^5 characters. How can we read a line of 10^5 chars in python and not get a runtime error? use sys.stdin instead of input() module Main where -------------------------------------------------------------------------------- toCandetat :: Char -> [Char] toCandetat '0' = "oqz" toCandetat '1' = "ij" toCandetat '2' = "abc" toCandetat '3' = "def" toCandetat '4' = "gh" toCandetat '5' = "kl" toCandetat '6' = "mn" toCandetat '7' = "prs" toCandetat '8' = "tuv" toCandetat '9' = "wxy" toCandetat n = error "unkown numb" -------------------------------------------------------------------------------- convertToCandedat :: String -> [String] convertToCandedat = map toCandetat -------------------------------------------------------------------------------- testWord :: String -> [String] -> Bool testWord str can = and $ zipWith elem str can -------------------------------------------------------------------------------- loop :: [String] -> String -> String loop [] acc = tail acc loop ["-1"] acc = tail acc loop in_str acc = loop next (acc ++ "\n" ++ fixPart) where fixPart = if part == "" then "No soluton." else part part = partSolve test cand [] (numb:count:xs) = in_str cand = convertToCandedat numb int_count = read count (test, next) = splitAt int_count xs -------------------------------------------------------------------------------- partSolve :: [String] -> [String] -> String -> String partSolve [] [] acc = tail acc partSolve (x:xs) can acc | testWord x can = skipX ++ nextXs | otherwise = partSolve xs can acc where lenX = length x skipX = partSolve xs can acc nextXs = partSolve xs (drop lenX can) (acc ++ " " ++ x) partSolve _ _ _ = "" -------------------------------------------------------------------------------- main :: IO () main = do in_str <- getContents putStr $ loop (words in_str) [] -------------------------------------------------------------------------------- Anti WA11 Test: #X# #OX XOO Crosses win Anti WA12 Test: #X# O#O XOX Crosses win I hope these tests will be useful for you....... thanks a lot, i've AC with your test! It turns out that wrong tests are given. In a condition it is told that one player can win party one course. And it turns out what not one. No! "Head Judge observed that one player was able to win the game in one move." But Head Judge could be wrong. :) Is that true? Or i shouldn't implement case when nobody could win in one move? My code answers correct to your test cases, but Online Judge is saying W#11, I cannot find any case my solution fails. Can you provide more test cases, pls? And how people find the test case, do they figure it out or is there any way to know? У меня WA 9 и эти тесты работают Try this X## O#X XOO Crosses win But description says that one of teams must win in one move if we imagine that its their turn So I think that this test cant be real My AC recursion for n=8 gives about 8250733 calls. What is the minimum recursive calls value? My recursion gives only 64 for n=8. I sort moves by count of free cells that can be reached from them. There are 3 problems, which can be solved stupidly in two ternary searches: 1755 (this), 1633, 1874 #include<stdio.h> int main() { int h, l; scanf("%d %d", &h, &l); int total = h + l; printf("%d %d\n", total - l - 1, total - h - 1); return 0; } Hi. I wonder, how can I solve it with dp? I thinked a whole day and cant find the solution less than O(N*T). Give me please some hint. Just sort by endtime and use greedy. It's that easy. Why does it work? Can you prove that approach? I don't understand why it does work :(. O(N * T)? What is 'T'? This can be solved using greedy, but the O(N^2) DP solution is as follows: 1) Sort by start times dp[i]: maximum events that can be attended
iterate from j = 0 to i-1, if end time of j-th conference is less than start time of i-th and dp[j] + 1 > dp[i] then dp[i] = dp[j] + 1 answer is max of all elements of dp array You should save dp[max(end_time)]; remember that for each end time there maybe different start times so that (end - start) are different. Save these segments, mp[end].push_back(end-start + 1); now check from 1 to max(end_time) and for each i, if i is end time? then check this segments sizes, for each such segment dp[i] = 1 + dp[i - s]; where s is saved segment sizes for end time 'i'. https://pastebin.com/C3dagNL2 Edited by author 30.04.2022 18:18Hint: we start from kk = 1, then kk += kk (2), kk += kk (4) but we cannot advance when kk > k. get to the maximum kk with this and the remaining n - kk can be easily calculated with (n - kk) / k + (((n - kk) % k) > 0) Or array of vector <bool>. It uses less memory too. |
|