Common Boardwhy is  k =10 and n =2 output =90 #include <stdio.h> #include <stdlib.h> #include <math.h> int main() { unsigned long long k[4]; for(int i=0;i<4;i++){     scanf("%llu",&k[i]);   } printf("\n"); printf("%.4f\n",sqrt(k[3])); printf("%.4f\n",sqrt(k[2])); printf("%.4f\n",sqrt(k[1])); printf("%.4f\n",sqrt(k[0]));   return 0; }   Ошибка на тесте 2 /Error in test 2   Edited by author 09.09.2018 15:45 Во входном потоке может быть любое количество чисел, а не только четыре. Почините алгоритм проверки! Не контачит на сях. Вот код: #include <stdio.h>   int main(int argc, char const *argv[]) {     int a, b;     a=1, b=5;     printf("%i\n", a+b);     return 0; } а с чего ты взял что вводимые данные будут целочисленные? В этом коде не считываются a и b из входного потока.   Edited by author 23.09.2018 18:34 Hello, everyone. Just wanted to summarize some info about this problem. Ok, my code got AC with following things in it: 1. My pi was 3.1415926535897932384626433 (perhaps it is enough) 2. I used this formula from wikipedia deltaArc=acos(sin(phiA)*sin(phiB)+cos(phiA)*cos(phiB)*cos(deltaL)); distance = deltaArc*3437.5; (see the first formula from wikipedia  http://en.wikipedia.org/wiki/Great-circle_distance)3. I used the following condition: if(100.00-distance>0.005) printf("DANGER!\n"); Hope it will help somebody. thanks a lot ...your formula is really useful.^_^ Used everynth what is written here. However still WA8. Any new ideas?... Do u know that pi can be calculated by this formula: atan(1) * 4? 1)Solution always exists and his complexity <= O(n^2) 2)Try to solve the problem when the permutation is n (n-1) ... (n-left+1) 1 2 3 ... right where left+right=n.    After O(n^2) steps you can get n 1 2 3 ... (n-1).    Then after O(n^2) steps you can get 1 2 3 ... n. 3)Try to reduce the problem to this permutation by O(n^2) steps. 4)Good to know: 1 2 3 ... t x-> 2 1 3 ... t x -> 3 1 2 4 ... t x -> 4 1 2 3 5 ... t x ->... -> t 1 2 3 ... (t-1) x -> x 1 2 3 ... t by t steps. I call this operation "Shift(t)".   Edited by author 26.07.2018 20:20 simplest solution: i=0..n-1 : while p[i] <> n do  change(p[i]);     Edited by author 22.09.2018 14:02 I can't think of a way to store goto and fail transitions of so many vertices and avoid MLE. please help.   here's code:   #include <stdio.h> #include <queue> using namespace std; short g[110000][256]; short f[110000]; short o[110000]; short n,m,newstate=0; queue<short>Q; int main(void){     short i,pos=0,q,r,u,v,ch,state;     scanf("%hd",&n);getchar();     for(i=1;i<=n;++i){         r=0;         ch=getchar();         state=0;         ++r;         ch+=128;         while(g[state][ch]){             state=g[state][ch];             ch=getchar();             ++r;             ch+=128;         }         while(ch!='\n'+128){             newstate=newstate+1;             g[state][ch]=newstate;             state=newstate;             ch=getchar();             ++r;             ch+=128;         }         o[state]=r-1;     }     for(i=0;i<256;++i){         if(q=g[0][i]){             f[q]=0;             Q.push(q);         }     }     while(!Q.empty()){         r=Q.front();         Q.pop();         for(i=0;i<256;++i){             u=g[r][i];             if(!(u==0&&r>0)){                 Q.push(u);                 v=f[r];                 while(g[v][i]==0&&v>0) v=f[v];                 f[u]=g[v][i];                 if(o[u]==0) o[u]=o[f[u]];             }         }     }     scanf("%hd",&m);getchar();     for(i=1;i<=m;++i){         q=0;r=0;         while((ch=getchar())!='\n'){             ch+=128;             ++r;             while(g[q][ch]==0&&q>0) q=f[q];             q=g[q][ch];             if(o[q]){                 printf("%hd %hd",i,r-o[q]+1);                 return 0;             }         }     }     printf("Passed\n");     return 0; } you got pretty close, modified your solution to get AC. let me know if you need hints :) ikhomeriki@gmail.com   Edited by author 21.09.2018 23:04 For TC: abracadabra abrabracada   why don't the prefixes are: abra abracada a?   and also   why for TC: abracadabra arbadacarba   the prefix is not: a? why don't the prefixes are: abra abracada a?   You can write this prefixes, this is the correct answer.   why for TC: abracadabra arbadacarba   the prefix is not: a?   Because the word must consist entirely of prefixes. #include <bits/stdc++.h> using namespace std; int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n,count = 1;     long long m, sum = 0;     vector<long long> coll;         vector<pair<long long, int>> coll1;     cin >> n;     while(n--)     {         cin >> m;         coll.push_back(m);     }     m = coll[0];     int i = 1;     if(coll.size() > 3){     for( ; i < coll.size(); ++i)         {            if(m <= coll[i] && count < 3)        {            count++;        } else            if( i>=3)            {                sum += coll[i-1];                sum += coll[i-2];                sum += coll[i-3];                coll1.push_back({sum, i-1});                sum = 0;                count = 1;            }        m = coll[i];        }        sort(coll1.begin(), coll1.end());        cout << coll1[coll1.size()-1].first << ' ' << coll1[coll1.size()-1].second  << endl;     } else     cout << accumulate(coll.begin(), coll.end(), 0) << ' '<<'2' << endl;        coll.clear();        coll1.clear();        return 0; } Irakli Khomeriki Stats 21 Sep 2018 01:24 It would be awesome to have stats for each task, like best/average time/memory of AC-ed solutions for each language. 4 0 0 0 0 0   Edited by author 23.05.2007 21:03 thanks, buddy it helped me use  ios_base::sync_with_stdio(false); cin.tie(0); with cin/cout. Don't forget to add last two digit's sum carry if it has. 5M is too much. It isn't necessary to get whole numbers in memory. if you read data as: double x; cin>>x; a[i]=x*100; it doesn't work! n = int(input())   l = list(map(int, input().split())) l1 = []   for i in range(n):     l1.append((l[i]//2 +1))   if n > 3:     k = (n // 2 + 1) // 2 + 1 #Groups which decline else:     k = (n // 2 + 1) // 2
  for i in range(k):     l1.remove(max(l1))   print(sum(l1))     Edited by author 15.09.2018 21:04 Just simplify ur code. This is very easy task. Bellow there is my ac solution: [code deleted]   Edited by moderator 20.11.2019 00:09 x[i] - y[i] = a * i + b   x[i-1] - y[i-1] = a * (i-1) + b   ------------------------------------   x[i] - x[i-1]  - ( y [i] - y[i-1] ) = a       Let x1[i] = x[i] - x[i-1], i > 0. and y1[i] = y[i] - y[i-1], for i>0.     so ,   x1[i] - y1[i] = a,  a = x1[0] - y1[0].   x1[i-1] - y1[i-1] = a ------------------------------- x1[i]  - x1[i-1] - (y1[i ] - y1[i-1]) = 0  or,   x1[i] - x1[i-1] = y1[i] - y1[i-1]   Let x2[i] = x1[i] - x1[i-1] = x[i] - 2*x[i-1] + x[i-2], for i>1. and     y2[i] = y1[i] - y1[i-1] = y[i] - 2*y[i-1] + y[i-2], for i>1.   so  x2[i] = y2[i],  for all 1 < i <= n.   Use KMP.   I didn't try this, yet ).     this may be true: 1.000 > 1. so add this func:     double acos1(double x)     {         if(x > 1)           x = 1;         if(x < -1)           x = -1;         return acos(x);     } Big thanks, god, without that, my program was stopped at test 8. It's actually 1.00000000000000001, not 1.000   BTW, same stuff should be applied to 'sqrt'. if(v<0 && v>-eps) v = 0; sqrt(v); Thank you very much! I had WA 24, "safe" acos didn't help, but "safe" sqrt did, I got AC. I used it so: double sqrt1(double a) {   if (a<0)     return 0;   return sqrt(a); }   Edited by author 31.07.2015 13:17 thanks a lot, never would have figured out :) THANKS!!!!!!!!!! It really helped me! After small fix - AC :) thanks so much, i got ac with your func... 1 4 1 1 1 2 3 4 Ans 5   6 5 50 1 4 6 6 2 5 2 5 10 14 15 Ans 21   6 5 4 1 4 6 6 2 5 2 5 10 14 15 Ans 13   9 5 4 2 4 2 5 3 1 7 2 3 5 6 9 10 14 Ans 22       just use dijkstra and that's all  |  
  |