Common BoardI'm newby here and I didn't solve this kind of tasks before. I know, that must be very easy, give me please some pieces of advice to solve it. Think abstractly! It's very easy! Edited by author 06.02.2014 05:58 Edited by author 06.02.2014 05:58 You can either take it the mathematical way, and solve it by induction: assume you know the number of ways for 1..N stripes, how to find out the ways for N+1? Or you can make a brute-force algorithm (backtracking) that simply counts and prints the number of ways for each N between 1 and 10-20 (until it gets too slow), then try to deduce a general rule for N, based on this series. Good luck! Hey, guys, it is not serious, really ...... I had wa4 with EPS = 1e-8 .... when I've changed EPS = 1e-6 I got AC... Edited by author 06.02.2014 18:13 Does anyone know what's this test like? using System; namespace ConsoleApplication4 { class Program { static void SQRT(UInt64 sum) { double ima_ans = Convert.ToDouble(Math.Sqrt(Convert.ToDouble(sum))); Console.WriteLine(Convert.ToDouble((Math.Round(ima_ans = ima_ans * 10000)) / 10000)); } static void Main(string[] args) { string save_str=null; string str = Console.ReadLine(); int i = str.Length; int k; UInt64 sum; i = i - 1; while (i >= 0) { k = 0; while (i >= 0 && str[i] != ' ') { k = 1; save_str += str[i]; i = i - 1; } sum = Convert.ToUInt64(save_str); if (sum > 0 && sum <= Math.Pow(10, 18) || k == 1) SQRT(sum); save_str = null; i = i - 1; } Console.ReadLine(); } } } Don't have any idea, give me that or similar test please. #include <iostream> using namespace std; int main() { int a,b; cin>>a; if(a==0 && a<=10000) cout<<"1"; else { if(a>0 && a<=10000) cout<<((a*(a+1))/2); else { if(a<=10000){ b=-((((-a)*((-a)+1))/2)-1); cout<<(b);} else cout<<"error";} } return 0; } Edited by author 05.02.2014 01:45 Ok, just search biggest prime number :) Edited by author 04.02.2014 22:13 more than one registrations ;) who can help me? I WA on #7.Why? here is my program: var a:array[1..1000]of longint; b:array[1..1000,1..1000]of boolean; n,i,j,x,y,m:longint; c:boolean; function find(x,y:longint):boolean; var i:longint; begin if b[x,y] then exit(false); for i:=1 to m do if (b[a[i],x])and(b[a[i],y])then begin b[x,y]:=true;b[y,x]:=true; exit(false); end; exit(true); end; begin while not seekeof do begin readln(x,y); b[x,x]:=true;b[y,y]:=true; b[x,y]:=true;b[y,x]:=true; c:=true; for j:=1 to m do if a[m]=x then begin c:=false;break;end; if c then begin inc(m);a[m]:=x; for i:=1 to m do if find(a[i],x) then begin writeln(0);halt; end; end; c:=true; for j:=1 to m do if a[m]=y then begin c:=false;break;end; if c then begin inc(m);a[m]:=y; for i:=1 to m do if find(a[i],y) then begin writeln(0);halt; end; end; end; writeln(1); end. Pls check for the following case: 5 6 5 8 5 9 6 7 8 9 9 10 Answer should be 1 Test 7 has invert vertexes. 10 1 1 2 asn: 1 I have many times WA, because my programm doesnt check it. [code deleted] Edited by author 10.09.2012 19:45 Edited by moderator 20.11.2019 00:11 OMG,how it was possible to come up with that? you should cout the answer only, without any "The minmum no of voters needed is" n = 3 1 2 0 0 2 3 0 0 0 3 1 0 n = 6 1 2 3 0 0 0 3 4 5 0 0 0 0 5 6 1 0 0 0 0 6 2 4 0 n = 10 1 2 3 4 0 0 0 0 4 5 6 7 0 0 0 0 0 7 8 9 1 0 0 0 0 0 9 10 2 5 0 0 0 0 0 10 3 6 8 0 n = 15 1 2 3 4 5 0 0 0 0 0 5 6 7 8 9 0 0 0 0 0 0 9 10 11 12 1 0 0 0 0 0 0 12 13 14 2 6 0 0 0 0 0 0 14 15 3 7 10 0 0 0 0 0 0 15 4 8 11 13 0 n = 21 1 2 3 4 5 6 0 0 0 0 0 0 6 7 8 9 10 11 0 0 0 0 0 0 0 11 12 13 14 15 1 0 0 0 0 0 0 0 15 16 17 18 2 7 0 0 0 0 0 0 0 18 19 20 3 8 12 0 0 0 0 0 0 0 20 21 4 9 13 16 0 0 0 0 0 0 0 21 5 10 14 17 19 0 n = 36 1 2 3 4 5 6 7 8 0 0 0 0 0 0 0 0 8 9 10 11 12 13 14 15 0 0 0 0 0 0 0 0 0 15 16 17 18 19 20 21 1 0 0 0 0 0 0 0 0 0 21 22 23 24 25 26 2 9 0 0 0 0 0 0 0 0 0 26 27 28 29 30 3 10 16 0 0 0 0 0 0 0 0 0 30 31 32 33 4 11 17 22 0 0 0 0 0 0 0 0 0 33 34 35 5 12 18 23 27 0 0 0 0 0 0 0 0 0 35 36 6 13 19 24 28 31 0 0 0 0 0 0 0 0 0 36 7 14 20 25 29 32 34 0 why? n=10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 9 10 1 10 ---- 9>6 is it wrong, why? Edited by author 18.04.2009 00:35 Edited by author 26.11.2010 13:52 Probably easier to grasp: n=10 5 4 1 2 3 4 4 1 5 6 7 4 2 5 8 9 4 3 6 8 10 4 4 7 9 10 n=15 6 5 1 2 3 4 5 5 1 6 7 8 9 5 2 6 10 11 12 5 3 7 10 13 14 5 4 8 11 13 15 5 5 9 12 14 15 Thanks to author! Edited by author 19.11.2014 21:49 Maybe, you know some tricks? input 6 00:00:00 00:00:01 00:00:02 00:00:03 00:00:04 00:13:00 AC output 00:13:58 00:13:58 00:13:58 00:13:58 00:13:58 00:16:46 perhaps you meant this test? 6 00:00:00 00:00:01 00:00:02 00:00:03 00:00:04 00:00:05 my output WA5 00:13:58 00:13:58 00:13:58 00:13:58 00:13:58 00:15:48 why 00:16:46? Can someone please explain this to me. See, kettles number 1 - 5 will drink coffee at the same time (00:13:58) and only in this time kettle number 6 may begin to boil water for himself ..... He will need 2:48 seconds for that. Why 2:48 ? ...... because in this time 200 ml water will be in the kettle with 20 degrees .... but kettle number 6 want 100 degrees in the main kettle .... then we take: deltaT = 100 - 20 = 80 C and P you know from statement m = 200 using formula from statement (deltaT = P * littleT / C * m) we will take that littleT = deltaT * C * m / P = 02:48 --- this is time that we need to boil water. Result : 00:13:58 + 00:02:48 = 00:16:46 #include <stdio.h> #include <math.h> int main(void) { long long number[1000000]; int i=0,k; while(scanf("%lld", &number[i++]) == 1); k=i-1; while(k>0) { printf("%.4lf\n", sqrt((double)number[--k])); } return 0; } while(scanf("%lld", &number[i++]) != EOF){/*...*/} #include<stdio.h> #include<math.h> unsigned long long int a,i,s[10000000]; int main() { double b; i=0; //freopen("input.txt","r",stdin); while(scanf("%llu",&a)!=EOF) { s[i]=a; i++; } while(i>0) { i--; b=sqrt(s[i]); printf("%.4lf\n",b); } return 0; } Plz use "%.4f" instead "%.4lf" to printf. :) why %.4lf is not acceptable? you are fool? this is no need reason ,this is fixed 格式 To use sqrt() from math.h you need to add -lf flag while compiling, I believe. Can`t understand what is the problem #include <stdio.h> #include <math.h> int main() { unsigned long long int a[4096], b; int counter=0; while(scanf("%llu", &b)) { a[counter]=b; counter++; }
for(int i=counter-1; i>=0; i--) printf("%.15Lg\n", (long double)sqrt(a[i])); return 0; } 1) while(scanf("%llu", &b) != EOF) 2) Maybe it's ok, but why do you printf("%.15Lg\n)? 4 symbols after the dot is not ennough, or I don't understand sth? Сan somebody tell whether it may be several current users at once? Может кто нибудь сказать, может ли быть несколько текущих пользователей сразу? Edited by author 01.02.2014 02:35 Yep, there must be an array with all active users. Нужен будет еще один массив для записи текущих (login) пользователей, у кого будет выбивать WA5. I tried to solve it with (dp[i] = sum_j(max(dp[j - 1], dp[i - j])) + 10) formula, but the way of getting the math expectation as max(dp[A], dp[B]) isn't right. Ho to do it? What is the formula..? please, help me... :( Add one more dimension to your DP oough, I still cant get it. What is the 2nd dimension? I divide the current line(C) to A and B... I really cant understand what else should I know or do to calc C. What else? You should actually know what is max you're trying to find expectation of! В FPC все работает, здесь же ... Вот код, помогите program f1; var f,f2:text; i,j:integer; a:array[1..130000] of real; begin assign(f,'input.txt'); reset(f); i:=0; While not eof(f) do begin inc(i); read(f,a[i]); end; close(f); assign(f2,'output.txt'); rewrite(f2); For j:=i downto 1 do writeln(f2,sqrt(a[j]):0:4); close(f2); End. 1) Статический массив? Зачем? Динамика тут идет гораздо лучше. 2) Файлы лучше использовать с директивой, т.к. местная проверочная система использует ввод с клавиатуры. здесь нельзя работать с файлами Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:) i disagree, my solution takes 0.046 seconds... and i use string, vector Do NOT use STL's strings, use standart C char arrays instead. That makes a HUGE difference in the time and memory complexity. I hope that this will be helpful to somebody:) STL string - TL 12, 10 MB used. Char arrays - AC 0.031, 1.24 MB used... I got TLE. But after changing "s1.size()" on "long ns1 = s1.size()" and "s2.size()" on "long ns2" got AC. =) And I changed "vector" on "deque"( for deleting elements from begining ). Edited by author 14.12.2011 16:27 Edited by author 14.12.2011 16:30 Got 0.062 and 1485 KB with pure STL and strings: just start your program with cin.sync_with_stdio(false); Btw, to get a O(n) solution consider that if a suffix of the last word is a prefix of the first word (check thru hash), then it is safe to assume that this suffix is in the answer. |
|