Common BoardI didn't do anything for 'arbitary' sequence. But my solution got accepted.Can anybody help me clear this doubt?     Edited by author 22.01.2019 18:38     Edited by author 09.03.2021 22:26 10 6 1 2 even 1 1 even 3 4 odd 5 6 even 1 6 even 7 10 odd   i think the answer of this data should be 1,but my program answer is 4 but it return an accepted! why?i think 4 is correct. "1 2 even" -> first 2 digits are 00 or 11 "1 1 even" -> first digit is 0. So if first 2 digits are 00, everything is ok sort(a + 1, a + 1 + n);   reverse(a + 1, a + 1 + n);     for(int i = 1; i <= n; i++){     if(sum1 > sum2){       sum2 += a[i];     }     else{       sum1 += a[i];     }   }     cout << abs(sum1 - sum2); let me give you an example 13 14 27 if I understand your solution you are sorting it and then add to left or to the right. in this example the diff is 0 what your program returns? The same thing. I tried to enter almost everything, it works correctly, but i always have WA on 5 test Test Case : 5 5 5 4 3 3 2 Test Case : 5 5 5 4 3 3     Edited by author 15.01.2019 16:49     Edited by author 06.11.2018 20:49 If you write on c++ you can do this:   char dot; unsigned int x,ip;   ip = 0;   for (int i = 24; i >= 8; i -= 8) {   cin >> x >> dot;   x <<= i;   ip |= x; } cin >> x; ip |= x; ------------------ Now you have ip, same you can read mask.   Edited by author 21.01.2019 14:50   Edited by author 21.01.2019 14:52 На Паскале не работает код если начать его так:   read(n); read(s); (или readln(s))   n - longint, s - string   Но если так:   readln(s);   А затем разрезать на n и s1, то всё ОК. Разве так и должно быть? #include <iostream> using namespace std;  long long  a,b,t,c,d,k,s,f;   int main () {     c = 1; k = 0;    cin >>t;    for (t;t>=1;--t) {      cin >>a;       cin >>b;    if ( b%a==0)    {        for( ; d != b; ++c )        {          d = a*c;           if ( b % d == 0)           {               k= k+1;               a = d;               c = 1;           }        }        cout << k<<"\n";    }    else       cout << "0\n";    c=1; k=0;    }     return 0;
  } Excuse me but your algo is wrong.   input: 5 1 1000000000 1 1000000000 1 1000000000 2 10 2 10   your answer: 19 0 0 2 0   right anse: 19 19 19 2 2   Check it up!.. Press any key to continue . . . Hi there! I'm curious regarding submission metrics time and memory. Is this the avg time and avg memory of all the tests or maximum time and maximum memory used in the worst test?   Can anybody please reveal how does the system count time and memory for different languages? I would like to reproduce it locally before the submission. I use golang. Thanks using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;   namespace phrase {     class Program     {         static int First(string input, string[]array)         {             int col = Convert.ToInt32(input.Length);             if (col>0&&col<=1000)             {                 int countArr = 0,countStr = 0,c = Convert.ToInt32(array.Length),count = 0,indexStr=0;                 for (; countArr < c; countArr++)                 {                     for (; (indexStr = input.IndexOf(array[countArr], countStr)) !=-1; countStr = indexStr + 1)                     {                         count++;                     }                     countStr = 0;                 }                 return count;             }             return 0;         }         static void Main(string[] args)         {             string[] one = new string[] { "a", "d", "g", "j", "m", "p", "s", "v", "y", ".", " " };             string[] two= new string[] { "b", "e", "h", "k", "n", "q", "t", "w", "z", "," };             string[] three = new string[] { "c", "f", "i", "l", "o", "r", "u", "x", "!" };             string input = Console.ReadLine();             int a = First(input,one);             int b = First(input,two);             int c = First(input,three);             Console.WriteLine(a+(b*2)+(c*3));         }     } }   var   i,n,l,j:longword; found:boolean; begin   readln(n);   repeat   found:=False;   for j:=3 to n div 2 do   begin     if n mod j=0 then     begin       found:=True;       break;     end;   end;   if found then n:=j;   until not found;   writeln(n-1);   readln; end.   Please help me to optimize my code. It's 0.405 sec    for j := 3 to sqrt(n) do  will help you :) > for j := 3 to sqrt(n) do  will help you :)   will it? for sqrt(8) = 2.8, but answer should be 4 - 1 = 3 #include<stdio.h> #include<stdlib.h> #define x 100000   int main() {     long long int n , c=0,i;     double ar[x] = {};       while(scanf("%lld",&n)){         if(n < 0) break;         ar[c++] = n;     }       for(i=c-1; 0<=i; i--){         printf("%.4lf\n",sqrt(ar[i]));     }       return 0; } var
    i, n: integer;   c : real;   begin   read(n);   c := 0;   if n > 0 then   begin     for i := 1 to n do       c := n;     write(c);   end;   if n <= 0 then   begin     for i := 1 downto n + 1  do       c := (-((-n) * (1 - n) / 2) + 1);     write(c);   end; end.   Доп. примеры/add. examples: n=-5 -5+(-4)+(-3)+(-2)+(-1)+0+1   n=5 5+4+3+2+1   n=0 0+1   Арифмет. прогрессия/arithm. progression I think the answer is probablye Yes... I think it is relating to the number of inverse pairs of permuation.. Be sure that(at least for the given interval, [4,2*10^9]) every even number can be shown as sum of two prime numbers.   1. if n is prime, {n} 2. if n is even, {n = p1 + p2} 3. if n is odd   {n = 3 + p1 + p2} ( n-3 is even, so that recall second case.)   For convenience, prime numbers under 10^5 can be initialized.   Edited by author 03.12.2012 03:00   Edited by author 03.12.2012 03:00 prove it :) If he could proof it, he would get 1 thousand million dollar   Edited by author 02.08.2015 20:59 > if n is odd   {n = 3 + p1 + p2} ( n-3 is even, so that recall second case.)   IMO this is wrong. 85 = 2 + 83 is the counter-case.   > For convenience, prime numbers under 10^5 can be initialized.   this way too big. :)   Edited by author 12.01.2019 19:53   Edited by author 12.01.2019 19:54 Weird.   Edited by author 12.01.2019 12:15 C++ costs 200 kb (Visual C++ and 400 kb other compilers).  |  
  |