結果
問題 | No.906 Y字グラフ |
ユーザー |
![]() |
提出日時 | 2019-10-11 22:59:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 885 bytes |
コンパイル時間 | 2,150 ms |
コンパイル使用メモリ | 74,388 KB |
実行使用メモリ | 50,512 KB |
最終ジャッジ日時 | 2024-11-25 09:04:23 |
合計ジャッジ時間 | 4,644 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
import java.io.BufferedReader;import java.io.InputStreamReader;import java.math.BigInteger;public class Main {public static void main(String[] args) throws Exception {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));long n = Long.parseLong(br.readLine()) - 1;br.close();BigInteger bi1 = BigInteger.valueOf(n - 1);BigInteger bi2 = BigInteger.valueOf(n - 2);BigInteger bi3 = BigInteger.valueOf(2);BigInteger bi = bi1.multiply(bi2).divide(bi3);long ans = (n - 1) / 2;if (n % 3 == 0) {ans--;}BigInteger bi4 = BigInteger.valueOf(ans * 3);bi = bi.subtract(bi4);if (n % 3 == 0) {ans++;bi = bi.subtract(BigInteger.ONE);}ans %= 1000000007;bi = bi.divide(BigInteger.valueOf(6));bi = bi.mod(BigInteger.valueOf(1000000007));ans += bi.intValue();ans %= 1000000007;System.out.println(ans);}}