結果
| 問題 | No.87 Advent Calendar Problem |
| コンテスト | |
| ユーザー |
tanzaku
|
| 提出日時 | 2014-12-07 02:32:14 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,097 bytes |
| 記録 | |
| コンパイル時間 | 30 ms |
| 最終ジャッジ日時 | 2026-03-04 21:46:42 |
| 合計ジャッジ時間 | 301 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
ed7b36ba9187
[/j_bin/judge_tool judge 40000 CompileMemory.txt /dev/null sud /dev/null _ python3 java_util.py code Main.java java]
strconv.Atoi: parsing "CompileMemory.txt": invalid syntax
goroutine 1 [running]:
runtime/debug.Stack()
/home/yuki2006/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/src/runtime/debug/stack.go:26 +0x5e
main.main.func1()
/home/yuki2006/gopath/src/yukicoder/judge/main.go:22 +0x57
panic({0x7d6880?, 0xc0000f6210?})
/home/yuki2006/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/src/runtime/panic.go:783 +0x132
main.judgeMain({0xc000012100, 0x5?, 0x0?})
/home/yuki2006/gopath/src/yukicoder/judge/judge_linux.go:121 +0x4b1
main.main()
/home/yuki2006/gopath/src/yukicoder/judge/main.go:97 +0x277
ソースコード
import java.util.*;
public class Main {
static boolean isLeapYear(long y) {
return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
static long func(long n) {
long cnt1 = 0;
long LOOP = 400 * 7;
long d = 0;
for(int i = 1; i <= LOOP && 2014 + i <= n; i++) {
d += isLeapYear(i + 2014) ? 2 : 1;
if(d % 7 == 0) cnt1++;
if(2014 + i == n) {
return cnt1;
}
}
long ans = (n - 2015) / LOOP * cnt1;
d = d % 7 * (n - 2015) / LOOP % 7;
for(long i = (n - 2015) / LOOP * LOOP + 2015; i <= n; i++) {
d += isLeapYear(i) ? 2 : 1;
if(d % 7 == 0) ans++;
}
return ans;
}
public static void main(String[] args) {
/*
for(int i = 2015; i <= 10000; i++) {
int ans = 0;
int d = 0;
for(int j = 2015; j <= i; j++) {
d += isLeapYear(j) ? 2 : 1;
if(d % 7 == 0) ans++;
}
if(ans != func(i)) {
System.err.println(i + " " + ans + " " + func(i));
}
}
if(true) return;
*/
try(final Scanner sc = new Scanner(System.in)) {
System.out.println(func(sc.nextLong()));
}
}
}
tanzaku