Submission #59845


Source Code Expand

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	static InputStream is;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		int n = ni(), m = ni();
		out.println(n*(n+1)*(2*n+1)/6%m);
	}
	
	public static void main(String[] args) throws Exception
	{
		long S = System.currentTimeMillis();
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
		long G = System.currentTimeMillis();
		tr(G-S+"ms");
	}
	
	static boolean eof()
	{
		try {
			is.mark(1000);
			int b;
			while((b = is.read()) != -1 && !(b >= 33 && b <= 126));
			is.reset();
			return b == -1;
		} catch (IOException e) {
			return true;
		}
	}
		
	static int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}

Submission Info

Submission Time
Task A - 団子とうさぎ
User uwi
Language Java (OpenJDK 1.7.0)
Score 50
Code Size 1465 Byte
Status AC
Exec Time 580 ms
Memory 18948 KB

Judge Result

Set Name All
Score / Max Score 50 / 50
Status
AC × 30
Set Name Test Cases
All case_000.txt, case_001.txt, case_002.txt, case_003.txt, case_004.txt, case_005.txt, case_006.txt, case_007.txt, case_008.txt, case_009.txt, case_010.txt, case_011.txt, case_012.txt, case_013.txt, case_014.txt, case_015.txt, case_016.txt, case_017.txt, case_018.txt, case_019.txt, case_020.txt, case_021.txt, case_022.txt, case_023.txt, case_024.txt, case_025.txt, case_026.txt, case_027.txt, case_028.txt, case_029.txt
Case Name Status Exec Time Memory
case_000.txt AC 450 ms 18948 KB
case_001.txt AC 516 ms 18732 KB
case_002.txt AC 486 ms 18740 KB
case_003.txt AC 568 ms 18732 KB
case_004.txt AC 505 ms 18736 KB
case_005.txt AC 580 ms 18744 KB
case_006.txt AC 479 ms 18668 KB
case_007.txt AC 423 ms 18728 KB
case_008.txt AC 474 ms 18744 KB
case_009.txt AC 489 ms 18740 KB
case_010.txt AC 466 ms 18740 KB
case_011.txt AC 538 ms 18744 KB
case_012.txt AC 439 ms 18724 KB
case_013.txt AC 446 ms 18748 KB
case_014.txt AC 418 ms 18740 KB
case_015.txt AC 457 ms 18792 KB
case_016.txt AC 394 ms 18732 KB
case_017.txt AC 473 ms 18856 KB
case_018.txt AC 428 ms 18744 KB
case_019.txt AC 542 ms 18760 KB
case_020.txt AC 414 ms 18852 KB
case_021.txt AC 479 ms 18768 KB
case_022.txt AC 453 ms 18788 KB
case_023.txt AC 447 ms 18672 KB
case_024.txt AC 534 ms 18724 KB
case_025.txt AC 472 ms 18732 KB
case_026.txt AC 436 ms 18708 KB
case_027.txt AC 464 ms 18728 KB
case_028.txt AC 463 ms 18868 KB
case_029.txt AC 413 ms 18728 KB