Common BoardWhen will it be available on archive to submit? for the given 5 sample how 4 values 0 0 1 0 are coming. please explain anybody 1101001000 1 0 0 0 0 k: 1234567891011 example: k = 2 ==> 1 k = 3 ==> 0 k = 7 ==> 1 You must know how to generate the sequence first! And then the input gives the position for the given 5 sample how 4 values 0 0 1 0 are coming. please explain anybody ёпт, ну и условие=( Statement is more than clear. Solution is not that trivial. I can not understand this string "Help Vova to find such M, which maximizes the probability that exactly m out of n random passers-by speak Cantonese." What does it mean? This means exactly what is written - for any possible M there is some probability that, when taken n people out of N, exactly m of them will speak Cantonese. You want to estimate M in a way to maximize that probability. This is called maximum likelihood approach in statistics. My code: #include <iostream> using namespace std; double fac(int n) { double l = 1.0; for(int i = 1; i <= n; i++) l *=i; return l; } double A(int m, int n) { return fac(m)/fac(m-n); } void main() { int n; double soni = 0; cin >> n;
for(int i = 2; i<=n; i++) { soni += A(n,i); }
cout.precision(0); cout << fixed << soni; } WA#13 Where is my mistake? pls help me i have met the same problem with u Precision Edited by author 28.01.2012 00:07 Edited by author 28.01.2012 00:07 primer 21=138879579704209680000 19=330665665962403980 20=6613313319248079980 0-1 2-2 3-12 4-60 5-320 6-1950 7-13692 8-109592 9-986400 10-9864090 11-108505100 12-1302061332 13-16926797472 14-236975164790 15-3554627472060 16-56874039553200 17-966858672404672 18-17403456103284402 19-330665665962403980 20-6613313319248079980 21-138879579704209680000 What is the right answer in test 19 ? Edited by author 22.06.2013 15:11 If you use BigInteger the program is e-a-s-y :) Got AC from the first try :) Not only Java, but Python and Ruby as well. Edited by author 22.06.2013 14:08 can someone please explain the problem, specially the part "(parallel to the north-south or east-west directions or at the angle 45° to them)" and the first sample input-output. At last I have understood the problem (thanks to Fahim and Sadia). You have to consider either north-south, or east-west or diagonal straight lines; consider which yields highest amount of crop of a kind instead of all of them together. More clearly, for first test, SsS sSs SsS my confusion was _s_ s_s _s_ we can get a ring of 4 's' ... so the ans should be s 4 but later my friends explained consider only one straight line,which ever produces most as S__ _S_ __S or _s_ s__ ___ or ___ __s _s_ Hope my problem helps other. Here's my code: #include<iostream> using namespace std; int pri[20000],pr[4040000]; void p() { memset(pr,0,sizeof(pr)); int i,j; for(i=2;i<=1500;i++) for(j=i*i;j<4000000;j+=i)pr[j]=1; int kk=1; for(i=2;i<=4000000;i++) if(pr[i]==0)pri[kk++]=i; } int main() { int n,t; p(); while(scanf("%d",&n)!=-1) { while(n--) { scanf("%d",&t); printf("%d\n",pri[t]); } } return 0; } What's wrong with it?Who can help me? Edited by author 21.06.2013 21:02 Cheer up! Solved! Here's my code:(一个合适的范围是看来是很必要的啊!) #include<iostream> using namespace std; int pri[20000]; int pr[204000]; void p() { int i,j; for(i=0;i<=200000;i++)pr[i]=1; for(i=2;i<=447;i++) for(j=i*i;j<200000;j+=i)pr[j]=0; int kk=1; for(i=2;i<=200000&&kk<=15010;i++) if(pr[i])pri[kk++]=i; } int main() { int n,t; p(); while(scanf("%d",&n)!=-1) { while(n--) { scanf("%d",&t); printf("%d\n",pri[t]); } } return 0; } There are no zeroes in this test. because , input: n = 50 Length of output is 87 digits output : 682455418022864824778975492858747729001539122984270520078098343219608068466186523437500
Edited by author 21.06.2013 21:07 In one line more then one error. 1 ReadInt2() : int ReadInt(int) : int 2 int x = ReadInt2() int x = ReadInt(y) For Input : 10 -5 1 1 14 -5 2 2 3 3 19 0 0 Output1 : 2 -5 1 1 14 Output2 : 2 -5 2 1 14 Are both output1 and output2 considered as correct ? EDIT At least output2 is considered as CORRECT. (Finally solved :D) Edited by author 21.08.2013 18:18 I have tests many tests,with which I have found my program's mistakes,and maybe this tests can help you: 4 + 2 + 309 - 2 + 957 and the answer is: 2 1 309 3 but I got TLE at #18 now... Now I got TLE on #29 The mistake my program have is when I have done the discretization,I'll check a array whose length is n to refresh the order,then if we set o is the number after refreshing,we should set the ioop variables i=o rather than o=i... Now I got TLE on #29 The mistake my program have is that when I have done the discretization,I'll check a array whose length is n to refresh the order,then if we set o is the number after refreshing,we should set the loop variables i=o rather than o=i... Input 4 2 0 0 1 0 0 0 1 0 1 1 0 1 0 0 1 0 Output 2 1 1 4 4 1 1 2 2 4 4 2 only Uzbek from ADHAM!!! input: 4 TUT\TUT\TUT\TUT\TUT\TUT\TUT TUT\TUT\BUT\BUT\BUT BUT\TUT\TUT\TUT\TUT YUT\YUT\BUT\TUT\YUT output: BUT TUT TUT TUT TUT TUT TUT BUT BUT BUT TUT TUT TUT TUT TUT YUT YUT BUT TUT YUT input: 4 A\A\A\A\A\A\A A\A\A\A\B\B\B\B A\A\A\A\C\C\C\CB\B\B\V A\A\A\A\B\C\C\C\C\C\C output:
A A A A A A A B B B B C C C C C C C C C CB B B V Edited by author 19.06.2013 20:29 I have debug my program for two days,but I still cannot find any mistakes in my program. I wrote a program in order to make random tests,and I have used the accepted program to get the right answer and compare it to my program's answer.The result is right.... Edited by author 20.06.2013 11:01 Words can be easily hashed like: int hash = 0; while(..){ hash = hash * 31 + 'readed byte' } So equals will looks like: @Override public boolean equals(Object o) { return this.hash == o.hashCode(); } |
|