By padamprakash2014, history, 4 months ago, ,

for the problem http://codeforces.com/contest/914/problem/A

Your code here...

#include "bits/stdc++.h"
using namespace std;
const int N = 1e3 + 3;
const int M = 1e6 + 6;
int n;
int arr[N];
int mark[M];
int val;
int main(){
scanf("%d" , &n);
val = -M;
for(int i = 0 ; i * i < M ; ++i)
{
mark[i * i] = 1;
}
for(int i = 1 ; i <= n ; ++i)
{
scanf("%d" , arr + i);
if(arr[i] >= 0 && mark[arr[i]]){
continue;
}
val = max(val , arr[i]);
}
printf("%d\n" , val);
}

Also please explain the method of Input for long range of values.. I generally use long long int for such input range. is it good practice??

•
• -10
•

 » 4 months ago, # |   0 Auto comment: topic has been updated by padamprakash2014 (previous revision, new revision, compare).
 » 4 months ago, # |   0 He makes a table full of zeros, and marks the square numbers with a 1. Then for each number in the input he can check if it is square by looking if mark[i] is a one. Why would you use long long int? If you are not programming on a microcontroller or some really ancient device an int will have 32 bits, which is more than enough to store numbers in the range ~-2*10^9 — ~2*10^9.