Common BoardWe have recently translated StopStalk ( https://www.stopstalk.com ) to Russian language due to multiple requests from our Russian users. Please do check it out, you will surely love it if you are a Competitive Programmer :) a = input() from math import sqrt for q in a.split()[::-1]: print("%.4F" % sqrt(float(q))) input() would only take one line as input. Try using sys.stdin.read() . For testing, copy the input from example, paste it, press enter and CTRL+D import sys, math _in = sys.stdin.read() for nr in _in.split()[::-1]: print ("%.4f" % math.sqrt(float(nr))) Thanks it worked. Really not obvious thing here. is this problem supposed to be solved with random shuffling, or i just got lucky? You can have each pair exactly three times in the answer There is short solution which is easy to prove There is no test where A, B and C are on the same line and point A is between B and C (or C is between A and B). These are pretty tricky cases, maybe add them? Edited by author 21.01.2017 18:51 hello i have problem with my code and i dont know where is it T_T here is my code : var a:real; i,k:integer; z:array[1..100]of real; begin k:=1; while not eof do begin read(a); z[k]:=sqrt(a); k:=k+1; end; for i:=k-1 downto 1 do begin writeln(z[i]:0:4); end; end. Noise() - is constant, or linear, trigonometric, or random function??? #include <iostream> #include <stdio.h> #include <memory.h> #define NMAX 37 using namespace std; long cnt[NMAX]; int n; void genSum(int k, int sum); int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "rt", stdin); ///freopen("output.txt", "wt", stdout); #endif scanf("%d", &n); genSum (0 , 0); int answer = 0; for (int it = 9 * n / 2; it >= 0; --it) { answer += cnt[it] * cnt[it]; } printf("%d\n", answer); return 0; } void genSum(int k, int sum) { if (k == n / 2) { ++cnt[ sum ]; } else for (int digit = 0; digit <= 9; ++digit) { genSum(k + 1, sum + digit); } } My code is giving WA on test1. But it is giving correct ans for all these:- 50000 300 300 422791438 49999 299 299 505277419 25000 269 222 716603086 Can anyone provide more test cases? 24124 131 232 373638552 18000 234 279 653833015 34000 98 162 688357676 13452 134 245 900436780 10306 299 207 85275311 2 1 10 My output is: 2 1 2 2 2 2 2 2 2 2 2 Is this corret or Did I understand task wrong..? Please, Also tell me Test #5,6 Edited by author 14.09.2015 18:16 Други, кто-нибудь знает что это за несчастный тест? Проверил программу ВРУЧНУЮ в экселе для всех 50 значений "n", и всё сошлось. What's the problem? [code deleted] Edited by moderator 19.11.2019 22:58 Edited by author 17.01.2017 16:15 WA#10 s == t Edited by author 18.01.2017 00:46 AC! Hell yeah! Can you give me test №76? I'm not getting the bug in the code :(. It would be helpful if someone pointed the mistake. key = {'i' : 1, 'j' : 1, 'a' : 2, 'b' : 2, 'c' : 2, 'd' : 3, 'e' : 3, 'f' : 3, 'g' : 4, 'h' : 4, 'k' : 5, 'l' : 5, 'm' : 6, 'n' : 6, 'p' : 7, 'r' : 7, 's' : 7, 't' : 8, 'u' : 8, 'v' : 8, 'w' : 9, 'x' : 9, 'y' : 9, 'o' : 0, 'q' : 0, 'z' : 0 } while True: n = raw_input() if(int(n) == -1): break l = int(raw_input()) d = {} ans = [] for a0 in xrange(l): temp = raw_input() d["".join([str(key[i]) for i in temp])] = temp i = len(n) while(i>0): if n[0:i] in d.keys(): ans.append(d[n[0:i]]) n = n[i:] i = len(n)+1 i-=1 print "No solution." if len(n) != 0 else " ".join(ans) 43550 // hello 3 hell he llo -1 Народ, кто может указать на часть моего кода которая тормозит алгоритм? Чистил как мог, не смог выйти за 0.125 секунд import java.util.Scanner; public class Timus { public static void main (String[] args) { Scanner in = new Scanner(System.in);
byte m = in.nextByte(), n = in.nextByte();
System.out.println( (m*n-1)%2==0 ? "[second]=:]" : "[:=[first]");
in.close();
} } Всё нормально, просто джава медленная. Вон у вас задача a+b за 0.109. Спасибо за пояснение;) а каким же образом люди в топе выходят за 0.05 секунд? Вон первое место в А+B аж за 0.015 работает! Наверняка люди обходят стороной медленные методы и операции. Может вы знаете ресурс где можно почитать об этом? Поиск в гугле ни привёл ни к чем К сожалению, не могу сказать точно. Тут есть несколько моментов. Во-первых, более ранняя джава была быстрее, что можно увидеть по тому, что в основном большинство сабмитов, где указано java 1.5 / java 1.6, быстрее, чем те, в которых java 1.8. Конечно, этот сабмит а+б за 0.015 как раз на джаве 1.8, для меня это конечно странно. Может в коде в опциях был выставлен какой-то ключ для использования более ранней версии или типа того... Во-вторых, "общий" совет, который я могу дать — используйте BufferedReader (и если надо, StreamTokenizer) вместо Scanner'a, потому что последний в джаве обычно медленнее. (см. также код внизу страницы http://acm.timus.ru/help.aspx?topic=java&locale=ru). Хотя, конечно, для программ с маленьким объёмом входных данных разница не должна быть сильно критичной, но там где надо считывать со входа мегабайты — она очень ощутима. If the matrix size is 3, with the given contraints, it won't be "2 special cells", because 8 of them will be walls, and will be only one free cell. Could be that those special cells were located at the same place? Please drop some light on that. Thanks looks like someone has found a special case here ;) either 3x4 or 4x3 has two points, 3x3 does not using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { int k; int n; do { do{ n = int.Parse(Console.ReadLine()); } while (!(n >= 2)); do { k = int.Parse(Console.ReadLine()); } while (!(k >= 2 && k <= 10)); } while (!(n + k <= 18)); int start = (int)Math.Pow(10, n - 1); int end = 0; int check = start; int BigCount = 0; for (int i = n - 1; i >= 0; i--) end += (k - 1) * (int)Math.Pow(10, i); int h = end - start + 1; int o = 0; for (int l = 0; l < n; l++) { o += h % 10 * (int)Math.Pow(k, l); h = h / 10; } for (int i = 0; i < o; i++) { int count = 0; double p = check; for (int j = 0; j < n / 2; j++) { if ((p % 10 + p / 10 % 10) > 0) count++; p = p / 100; } if (count != 0) BigCount++; check++; count = 0; p = check; int r = 0; int m = 0; for (int l = 0; l < n; l++) { if (p % 10 == k) { count++; m += (10 - k) * (int)Math.Pow(10, l); r = 10 - k; } p += r; p = (int)p / 10; } check += m; } Console.Write(BigCount); } } Норм решение? Edited by author 16.01.2017 04:29 Edited by author 16.01.2017 04:30 This is my code: #include <iostream> #include <cmath> using namespace std; int main() { int a[101], n, x, dis1 = 0, dis2 = 0, lb, rb; bool flag = false, flag2 = false;
cin >> n >> x;
if ((x == 0)) flag2 = true; else { if ( n == 0 ) flag = true; }
for ( int i = 0; i < n; i++ ) { cin >> a[i]; if ( (x > 0) && (a[i] < x) && (a[i] > 0) ) flag = true; if ( (x < 0) && (a[i] > x) && (a[i] < 0) ) flag = true; }
if (flag) cout << "Impossible" << endl; else { lb = a[0]; rb = a[0]; for ( int i = 1; i < n; i++ ) { if ( (a[i] > 0) && (a[i] > rb) && (a[i] > x) ) rb = a[i];
if ( (a[i] < 0) && (abs(a[i]) < abs(lb)) && (a[i] < x) ) lb = a[i]; }
if ( x > 0 ) { dis1 = x; dis2 = (int) abs(2*lb) + x; } else { dis1 = 2*rb + (int) abs(x); dis2 = (int) abs(x); }
if (flag2) cout << "0 0" << endl; else cout << dis1 << " " << dis2 << endl; }
system("PAUSE"); return 0; } --------------------------- I can't understand WHY WA#4 Please, help!!! It's too hard code. The real solution is much easier/ My Code perfect AC with Visual Studio 2013, G++ 4.9, G++ 4.9 C++11. But Clang 3.5 gives output limit exceeded, or access violation.... Submit codes 7217044 7217043 Some bugs in the validator were fixed. The problem was rejudged. 299 WA submits turned to AC and 84 AC submits turned to WA. If you will find new bugs, please, write to timus_support (at) acm.timus.ru. Edited by author 09.09.2010 10:57 To those who have WA at 2 after rejudge: The ending point MUST have positive (STRICTLY) coordinates. Try this testcase: 1 1 1 2 2 4 2 3 to see if your answer satisfies the condition. Thx a LOOOOT of @198808xc. I got AC . if c0 less than all of other delay times: x = 0.003 ; y = sqrt(L*L - x*x)
|
|