Submission #11414441
Source Code Expand
import java.util.Scanner; final class Solver { static final Solver INSTANCE = new Solver(); void solve(Scanner sc) { int N = sc.nextInt(); int A = sc.nextInt(); int B = sc.nextInt(); if (A > B) { System.out.println(0); return; } if (N == 1) { System.out.println(A == B ? 1 : 0); return; } long min = Math.addExact(Math.multiplyExact(A, N - 1L), B); long max = Math.addExact(Math.multiplyExact(B, N - 1L), A); System.out.println(max - min + 1); } } class Main { public static void main(String... args) { Scanner in = new Scanner(System.in); Solver.INSTANCE.solve(in); in.close(); } }
Submission Info
Submission Time | |
---|---|
Task | A - A+...+B Problem |
User | Kina |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 661 Byte |
Status | AC |
Exec Time | 93 ms |
Memory | 21972 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, s1.txt, s2.txt, s3.txt, s4.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 92 ms | 18516 KB |
02.txt | AC | 91 ms | 21972 KB |
03.txt | AC | 90 ms | 18644 KB |
04.txt | AC | 92 ms | 19412 KB |
05.txt | AC | 92 ms | 20948 KB |
06.txt | AC | 92 ms | 20820 KB |
07.txt | AC | 92 ms | 20816 KB |
08.txt | AC | 93 ms | 19284 KB |
s1.txt | AC | 93 ms | 20308 KB |
s2.txt | AC | 92 ms | 21588 KB |
s3.txt | AC | 92 ms | 16980 KB |
s4.txt | AC | 92 ms | 19028 KB |