Common Board| Show all threads Hide all threads Show all messages Hide all messages | | I wan to know the key to this problem,who can tell me? | GaoHughes | 1044. Lucky Tickets. Easy! | 10 Apr 2012 20:37 | 3 | I know the meaning of this problem,but I just can't find a good way to solve it!! So who can tell me ? Thank you! I use C++ Edited by author 06.09.2010 20:15 Brute force: you just look through all possible numbers and choose lucky ones You can backtrack for 2, 4, 6, 8 and see what your program's answers are. Then you can simply put the answers. | | my AC solution with 0.015s 220KB | sahand | 1028. Stars | 9 Apr 2012 05:52 | 3 | MY ALGO TIME CONSUMED IS(250+128)*N unit my method is: divide distance between [0,32000] to 128 sector each sector is total of stars that occured in that portion hence for each x, level x calcute of bottom formula level = sector[x/250]+ Xpivot[i] that i=int(x/250)*250 to x in last update value of all sector that indexs greater than this sector index; Nevermind Edited by author 09.04.2012 06:01 | | Why should I got WA2? It seems very easy to solve. | z | 1294. Mars Satellites | 7 Apr 2012 23:45 | 5 | {$N+} Program Mars_satellites; Var cos_,x,a,b,c,d:Double; Begin Readln(a,b,c,d); If (a*b-c*d)=0 Then Begin Write('Impossible'); End Else Begin cos_:=a*a+b*b-c*c-d*d; cos_:=cos_/(2*a*b-2*c*d); x:=a*a+b*b-2*a*b*cos_; x:=sqrt(x); x:=round(1000*x); Write('Distance is ',x:0:0,' km.'); End; End. Hi, your program has two mistakes, first one is (a*b-c*d)=0, equlity cannot be tested with doubles that way, you should use Abs(a*b-c*d)<e instead, where e is very small value, in this case e=0.01 is enough; second mistake is the formula I think, try to solve the math part of this problem again. If you want I can send you my AC program ( or just it's formula ). ...то выведите "Impossible.", иначе... "Impossible{.}" who said the numbers were double? they are small integers... And the formula is very good... | | Test 11 | nbodea | 1083. Factorials!!! | 7 Apr 2012 14:06 | 1 | I don't know what's wrong, but it seems that i get wrong answer on test 11. Do you have any idea what it contains? | | Help with Test data #8 | __Emiapwil__ | 1027. D++ Again | 7 Apr 2012 14:04 | 2 | Hey, everybody! I'd like to ask for a test data of this problem similar to test #8. I've read through the discussions and passed all the test data given in earlier topics but still got stuck at #8. Any help will be appreciated!! Edited by author 07.04.2012 14:05 I've figured out the problem! It seems that I'm not familiar with the 'feof' function's action. In fact earlier discussions mentioned it but since the vim editor appends a newline in the end of my test input file I was unable to notice this. May this be of any help for those who meet the same problem. | | Problem 1085. Встреча | RocBoy-D | | 7 Apr 2012 00:17 | 1 | wa #21. Can anybody help me? Program P1; Var Map: Array[1..100,1..100] of Integer; S,G,F: Array[1..100] of Integer; A,I,B,J,N,M,K,L,P,R: Integer; Begin Readln(N,M); For A:=1 to N do For B:=1 to N do Map[A,B]:=16000; For I:=1 to M do begin Read(L); For J:=1 to L do Read(S[J]); For A:=1 to L do For B:=1 to L do Map[S[A],S[B]]:=1; End; For A:=1 to N do For B:=1 to N do For I:=1 to N do If Map[A,B]>Map[A,I]+Map[I,B] then Map[A,B]:=Map[A,I]+Map[I,B]; Read(K); A:=0; For I:=1 to K do begin Readln(G[I],S[I],F[I]); A:=A+G[I]; End; P:=0; R:=P; For I:=1 to N do begin P:=0; For J:=1 to K do begin If I=S[J] then begin P:=P+G[J]; continue; End; If Map[I,S[J]]=16000 then begin P:=0; Break; End; If (Map[I,S[J]]*4>=G[J]) and (F[J]=0) then begin P:=0; Break; End; If F[J]=1 then begin P:=P+G[J]; Continue; End; P:=P+G[J]-Map[I,S[J]]*4; End; If P>R then begin R:=P; L:=I; End; End; If R<>0 then Writeln(L,' ',A-R) else Writeln(0); End. | | To people who got WA 6 | Prabhjot Singh | 1654. Cipher Message | 5 Apr 2012 22:54 | 4 | try this test case dfadfmmmmfad Correct answer dfadad Hope this helps... Hi, I am getting "fd" as answer as shown below after each removal of duplicate characters. dfadfmmmmfad dfadad dfdd fd Could you please explain where am I wrong?? Thanks in advance. Anupam Why are you removing "a" chars in "dfadad"? You can delete it if chars stays together in the string. | | WA12 | diviator | 1837. Isenbaev's Number | 5 Apr 2012 22:06 | 1 | WA12 diviator 5 Apr 2012 22:06 Could somebody give me 12 test ? Sory for bad my English... | | Check error. wrong Accept | LostInSpace | 1005. Stone Pile | 5 Apr 2012 18:02 | 1 | Some incorrect algorythm has a wrong "Accept" test: 6 9 8 6 5 4 1 | | a problem with the first test | DEAL | 1471. Distance in the Tree | 5 Apr 2012 15:31 | 2 | here is my program it works right on the first test on my PC but here it fails!!! I even don't know what's the problem. I hope that the first test is the same as in the text, otherwise there's really something wrong with the pro. #include <iostream> #include <vector> #include <utility> using namespace std; #define MaxN 50010 #define MaxLogN 20 #define MaxM 75010 vector< pair<int,int> > list[MaxN]; int pr1[MaxN][MaxLogN]; //array of 2^i -th ancestor with the cost int pr2[MaxN][MaxLogN]; int tin[MaxN]; int tout[MaxN]; int used[MaxN]; int l=MaxLogN; int timer=0; void dfs(int v, int p, int cost) { used[v]=1; tin[v]=timer; timer++; pr1[v][0]=p; pr2[v][0]=cost; for(int i=1; i<l; i++) { pr1[v][i]=pr1[pr1[v][i-1]][i-1]; pr2[v][i]=pr2[v][i-1] + pr2[pr1[v][i-1]][i-1]; } for(int i=0; i<list[v].size(); i++) { if(used[list[v][i].first]==0) dfs(list[v][i].first,v,list[v][i].second); } tout[v]=timer; timer++; } int upper(int a,int b) { if(tin[a]<=tin[b] && tout[b]<=tout[a]) return 1; return 0; } int lca(int a,int b) { //a - ancestor if(upper(a,b)==1) { int i=0; while(upper(pr1[b][i],a)==0 && i<l) i++; i--; if(pr1[b][i+1]==a) return pr2[b][i+1];
return pr2[b][i]+lca(a,pr1[b][i]); } //b - ancestor if(upper(b,a)==1) return lca(b,a); for(int i=0; i<l; i++) { if(upper(pr1[a][i],b)==1) { if(i==0) return pr2[a][i]+lca(pr1[a][i],b); return(pr2[a][i-1]+lca(pr1[a][i-1],b)); } } } int main() { memset(used,0,MaxN*sizeof(used[0])); memset(pr1,0,MaxN*MaxLogN*sizeof(pr1[0][0])); memset(pr2,0,MaxN*MaxLogN*sizeof(pr2[0][0])); /*freopen("INPUT.txt","r",stdin); freopen("OUTPUT.txt","w",stdout);*/
int n,m; cin>>n; for(int i=0; i<n-1; i++) { int a,b,w; cin>>a>>b>>w; list[a].push_back(make_pair(b,w)); list[b].push_back(make_pair(a,w)); } dfs(0,0,0); cin>>m; int ans[MaxM]; for(int i=0; i<m; i++) { int a,b; cin>>a>>b; ans[i]=lca(a,b); } for(int i=0; i<m-1; i++) cout<<ans[i]<<"\n"; cout<<ans[m-1]; } sorry, i've solved it easier. | | English and Russian are different! | xurshid_n | 1843. Cutting a Parallelepiped | 4 Apr 2012 14:32 | 1 | | | I did not think that it is so easy! | JAVATAR | 1496. Spammer | 4 Apr 2012 02:30 | 1 | | | I have WA7, can you give me some tests please. | mohamed | 1788. On the Benefits of Umbrellas | 4 Apr 2012 00:59 | 2 | | | All tests here | Ezio - Altair | 1070. Local Time | 3 Apr 2012 20:10 | 3 | 01.01 21.59 04.23 11.22 Answer: 5 12.00 15.00 20.00 21.00 Answer: 1 23.58 00.43 22.27 03.10 Answer: 2 12.00 15.00 01.02 03.07 Answer: 0 01.01 10.59 04.23 04.22 Answer: 5 23.42 01.14 08.10 17.51 Answer: 4 On 4th your test my AC programm returns 143165577 O_o So this test is incorrect :) my AC program gives 0 did you use unsigned?? | | help wrong answer test #8 | jxhuzs | 1014. Product of Digits | 3 Apr 2012 14:38 | 1 | I use long long int with MinGW and have right answer for the input of 1000000000.Why it is still wrong? Here is my C code. #include<stdio.h> #include<math.h> #include<stdlib.h> int sum(int a); int main() { int count[10],i,j,base=0; //use count[2] to count [9] to store the number of digits long long int n,product=0; for(i=0;i<10;i++) count[i]=0; scanf("%lld",&n); if(n==1) printf("%d\n",1); else if(n==0) printf("%d\n",10); else{ for(i=9;i>1;i--){ while(n%i==0){ n/=i; count[i]++; } } if(n==1){ /* for(i=2;i<=9;i++){ for(j=0;j<count[i];j++){ printf("%d",i); } } */ for(i=9;i>=2;i--){ product=product+i*sum(count[i])*pow(10,base); base=base+count[i]; } printf("%lld",product); } else printf("%d",-1); printf("\n"); } system("pause"); return 0; } int sum(int a) { int term=1,i,result=0; for(i=0;i<a;i++){ result+=term; term*=10; } return result; }
| | What is the answer to 1A | SpartakusMd | 1893. A380 | 3 Apr 2012 14:24 | 2 | Hi. What is the answer to 1A "window" or "aisle"? | | C# What is wrong? | AC_Cobra | 1068. Sum | 3 Apr 2012 12:33 | 3 | I have checked all known numbers - result is right. When I submit code, system writes: Wrong answer. Where is error? Thank You! using System; class Program { static void Main() { int a = int.Parse(Console.ReadLine()); int r = 0; if (a <= System.Math.Abs(10000)) { if (a > 1) { for (int i = 1; i <= a; i++) { r += i; } } if (a < 1) { for (int i = 1; i >= a; i--) { r += i; } } Console.WriteLine(r); } else throw new Exception("Wrong number"); } } Hi, how about the case when a = 1 ? It seems like you'll output 0 which is incorrect. Thank you! That was an error. | | Clarify | Radi Muhammad Reza | 1894. Non-Flying Weather | 2 Apr 2012 23:52 | 4 | Clarify Radi Muhammad Reza 30 Mar 2012 23:36 please, someone explain the test case. i don't get how it is 540.0 Look at this sentence attentively: "One of the passengers has found on the Internet a satellite image of the airport territory taken EXACTLY ONE MINUTE AGO" In worst case the trundercloud will hang out of airport after 600 seconds the passenger has taken the image. After a minute this value = 540. Edited by author 02.04.2012 23:53 | | Admins! | unlucky [Vologda SPU] | 1740. Deer is Better! | 2 Apr 2012 22:31 | 4 | Admins! unlucky [Vologda SPU] 1 Nov 2009 15:22 Statement of problem is incorrect! I think, that many users agree with me. Fix it or "fix" author of this problem. He is very crazy man(IMHO) The statement is correct, you are making an incorrect additional assumption that the statement implies that the Chukcha's speed must be constant. This is false. (Also, please stop insulting the author.) The statement is correct, you are making an incorrect additional assumption that the statement implies that the Chukcha's speed must be constant. As for finding maximum of time - it is right. But how he can achive point B with time, that is littler,then his animals could run? Edited by author 03.11.2009 15:28Speed of animals is not constant! | | WA 33 | George_Aloyan[PTS Obninsk] | 1507. Difficult Decision | 2 Apr 2012 11:51 | 2 | WA 33 George_Aloyan[PTS Obninsk] 1 Apr 2012 19:32 Just "norm" matrix after every calculating (a[i][j] make 1 if it was positive) or you will have overflow Re: WA 33 Smilodon_am [Obninsk INPE] 2 Apr 2012 11:51 You can only use matrix with boolean values, it looks more efficient and spectacular. |
|
|