OLOLO - Onotole needs your help editorial SPOJ - UCS - Unleash-Coding-Skills

Tuesday, 1 May 2018

OLOLO - Onotole needs your help editorial SPOJ - UCS

The link for this problem OLOLO - Onotole needs your help:

http://www.spoj.com/problems/OLOLO/

This is problem used to demonstrate the use of XOR  operation:

Let 'A' be number:

example:
 A (XOR) A = 0
A (XOR) 0  = 0

These two properties are used in this problem to obtain the number that occurs only one in the given input in OLOLO - Onotole needs your help problem.

The following is the solution for the problem OLOLO - Onotole needs your help in C.

#include <stdio.h>
int main()
{
    unsigned  long long  int n,t,i,j,k;
    j=0;
    scanf("%llu",&t);
    for(i=0;i<t;i++)
    {
    scanf("%llu",&n);
    j=j^n;
    }
    printf("%llu",j);
    return 0;
}


Happy Coding.............

No comments:

Post a comment