Submission #124395

#TimeUsernameProblemLanguageResultExecution timeMemory
124395KhalilBenGamraStrange Device (APIO19_strange_device)Java
0 / 100
365 ms122724 KiB
import java.util.*; import java.io.*; public class strange_device { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int n = scan.nextInt(); int a = scan.nextInt(); int b = scan.nextInt(); int count = 0; boolean [][] found = new boolean[10000][10000]; for (int i = 0; i < n; i++) { int f = scan.nextInt(); int l = scan.nextInt(); for (int j = f; j <= l; j++) { int x = ((j+(int)Math.floor(j/b))%a); int y = j % b; //System.out.println("("+x+","+y+")"); if(!found[x][y]){ count ++; found[x][y] = true ; } } } out.println(count); out.close(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...