結果

問題 No.1081 和の和
ユーザー RISE70226821RISE70226821
提出日時 2020-08-04 17:45:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 3,094 bytes
コンパイル時間 4,080 ms
コンパイル使用メモリ 76,552 KB
実行使用メモリ 56,120 KB
最終ジャッジ日時 2023-10-12 21:18:42
合計ジャッジ時間 6,451 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,480 KB
testcase_01 AC 120 ms
55,808 KB
testcase_02 AC 120 ms
55,476 KB
testcase_03 AC 128 ms
55,760 KB
testcase_04 AC 132 ms
55,996 KB
testcase_05 AC 122 ms
55,524 KB
testcase_06 AC 127 ms
55,796 KB
testcase_07 AC 130 ms
55,556 KB
testcase_08 AC 132 ms
55,520 KB
testcase_09 AC 131 ms
55,892 KB
testcase_10 AC 133 ms
56,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		// 入力
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		// 計算
		for(int tail = N-1; tail > 0; tail--){
			for(int i = 0; i < tail; i++){
				A[i] = (A[i] + A[i+1]) % 1000000007;
			}
		}
		
		// 出力
		System.out.println(A[0]);
	}

	// 関数
	public static void name(){
	}

	// 文字列のx文字目を取得する関数
	public static String getPos(String str, int pos){
		return String.valueOf(str.charAt(pos));
	}

	// int型ロガー関数
	public static void loggerInt(String name, int num){
		String str = "";
		str += name;
		str += " = ";
		str += num;
		System.out.println(str);
	}

	// Long型ロガー関数
	public static void loggerLong(String name, Long num){
		String str = "";
		str += name;
		str += " = ";
		str += num;
		System.out.println(str);
	}

	// double型ロガー関数
	public static void loggerDbl(String name, double num){
		String str = "";
		str += name;
		str += " = ";
		str += num;
		System.out.println(str);
	}

	// String型ロガー関数
	public static void loggerStr(String name, String prm){
		String str = "";
		str += name;
		str += " = ";
		str += prm;
		System.out.println(str);
	}

	// boolean型ロガー関数
	public static void loggerBool(String name, boolean bool){
		String str = "";
		str += name;
		str += " = ";
		str += bool;
		System.out.println(str);
	}

	// int型配列ロガー関数
	public static void loggerIntAr(String name, int[] ar){
		String str;
		for(int i = 0; i < ar.length; i++){
			str = "";
			str += name;
			str += "[" + i + "]";
			str += " = ";
			str += ar[i];
			System.out.println(str);
		}
	}

	// Long型配列ロガー関数
	public static void loggerLongAr(String name, Long[] ar){
		String str;
		for(int i = 0; i < ar.length; i++){
			str = "";
			str += name;
			str += "[" + i + "]";
			str += " = ";
			str += ar[i];
			System.out.println(str);
		}
	}

	// double型配列ロガー関数
	public static void loggerDblAr(String name, double[] ar){
		String str;
		for(int i = 0; i < ar.length; i++){
			str = "";
			str += name;
			str += "[" + i + "]";
			str += " = ";
			str += ar[i];
			System.out.println(str);
		}
	}

	// String型配列ロガー関数
	public static void loggerStrAr(String name, String[] ar){
		String str;
		for(int i = 0; i < ar.length; i++){
			str = "";
			str += name;
			str += "[" + i + "]";
			str += " = ";
			str += ar[i];
			System.out.println(str);
		}
	}

	// boolean型配列ロガー関数
	public static void loggerBoolAr(String name, boolean[] ar){
		String str;
		for(int i = 0; i < ar.length; i++){
			str = "";
			str += name;
			str += "[" + i + "]";
			str += " = ";
			str += ar[i];
			System.out.println(str);
		}
	}
}
0