java - Scanner class input issues -


hi trying solve large input of fair , square of google code jam of year. have got enough fast working code large problem 1. when paste input in console not read of it. infact reads last input reason. want paste input , output. scanner class causing problem?

code :

import java.util.scanner; class rishab {  public static int check() {  scanner reader = new scanner(system.in);  double a=reader.nextlong();  long b=reader.nextlong();  int count = 0;  long i;  if((long)math.sqrt(a)==math.sqrt(a))    i= (long)math.sqrt(a);  else   i=(long)math.sqrt(a)+1;  for(;i<=math.sqrt(b);i++) {  if(i==reverse(i) && math.pow(i,2)==reverse((long)math.pow(i,2)))   count++;  }  return(count);  }   public static long reverse(long number) {   long result = 0;   while (number != 0) {    long remainder = number % 10;      result = result * 10 + remainder;      number /= 10;  }  return result;  }   public static void main(string str[]) {  int[] a= new int[10000];   scanner reader = new scanner(system.in);  int t= reader.nextint();  for(int i=0;i<t;i++)  a[i]=check(); for(int i=0;i<t;i++)  system.out.println("case #"+(i+1)+": "+a[i]); } } 

now problem if example paste input :

5 1 100 2 200 1 500 1 1000000 1 1000000000 

it wont work if type each line separately work do can paste input? thanks

try this:

string input =""; while (reader.hasnextline()){     input =  reader.nextline();     //parse each line     } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -