結果
問題 | No.732 3PrimeCounting |
ユーザー | claw88 |
提出日時 | 2018-09-20 11:54:30 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,740 ms / 3,000 ms |
コード長 | 3,225 bytes |
コンパイル時間 | 835 ms |
コンパイル使用メモリ | 113,288 KB |
実行使用メモリ | 26,288 KB |
最終ジャッジ日時 | 2024-07-18 08:31:03 |
合計ジャッジ時間 | 22,454 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 23 ms
24,252 KB |
testcase_01 | AC | 22 ms
25,904 KB |
testcase_02 | AC | 23 ms
23,872 KB |
testcase_03 | AC | 22 ms
26,044 KB |
testcase_04 | AC | 22 ms
23,740 KB |
testcase_05 | AC | 22 ms
26,052 KB |
testcase_06 | AC | 22 ms
23,988 KB |
testcase_07 | AC | 22 ms
23,988 KB |
testcase_08 | AC | 22 ms
23,868 KB |
testcase_09 | AC | 22 ms
23,876 KB |
testcase_10 | AC | 22 ms
23,992 KB |
testcase_11 | AC | 21 ms
23,996 KB |
testcase_12 | AC | 24 ms
26,032 KB |
testcase_13 | AC | 23 ms
21,936 KB |
testcase_14 | AC | 24 ms
23,752 KB |
testcase_15 | AC | 23 ms
23,992 KB |
testcase_16 | AC | 23 ms
23,864 KB |
testcase_17 | AC | 22 ms
23,996 KB |
testcase_18 | AC | 21 ms
23,864 KB |
testcase_19 | AC | 22 ms
24,112 KB |
testcase_20 | AC | 23 ms
24,156 KB |
testcase_21 | AC | 25 ms
25,972 KB |
testcase_22 | AC | 25 ms
26,032 KB |
testcase_23 | AC | 23 ms
26,028 KB |
testcase_24 | AC | 22 ms
23,732 KB |
testcase_25 | AC | 28 ms
23,992 KB |
testcase_26 | AC | 26 ms
24,112 KB |
testcase_27 | AC | 23 ms
25,948 KB |
testcase_28 | AC | 23 ms
24,156 KB |
testcase_29 | AC | 25 ms
21,684 KB |
testcase_30 | AC | 24 ms
25,824 KB |
testcase_31 | AC | 24 ms
21,936 KB |
testcase_32 | AC | 26 ms
23,836 KB |
testcase_33 | AC | 27 ms
23,964 KB |
testcase_34 | AC | 27 ms
25,900 KB |
testcase_35 | AC | 26 ms
26,000 KB |
testcase_36 | AC | 26 ms
26,128 KB |
testcase_37 | AC | 23 ms
23,992 KB |
testcase_38 | AC | 23 ms
23,992 KB |
testcase_39 | AC | 26 ms
23,828 KB |
testcase_40 | AC | 25 ms
23,864 KB |
testcase_41 | AC | 24 ms
25,908 KB |
testcase_42 | AC | 25 ms
26,044 KB |
testcase_43 | AC | 25 ms
24,176 KB |
testcase_44 | AC | 24 ms
25,968 KB |
testcase_45 | AC | 23 ms
25,952 KB |
testcase_46 | AC | 22 ms
23,860 KB |
testcase_47 | AC | 24 ms
26,084 KB |
testcase_48 | AC | 31 ms
21,812 KB |
testcase_49 | AC | 30 ms
23,856 KB |
testcase_50 | AC | 24 ms
21,940 KB |
testcase_51 | AC | 24 ms
22,196 KB |
testcase_52 | AC | 22 ms
26,072 KB |
testcase_53 | AC | 49 ms
23,852 KB |
testcase_54 | AC | 598 ms
24,152 KB |
testcase_55 | AC | 606 ms
24,380 KB |
testcase_56 | AC | 601 ms
24,636 KB |
testcase_57 | AC | 121 ms
21,800 KB |
testcase_58 | AC | 121 ms
25,904 KB |
testcase_59 | AC | 54 ms
21,936 KB |
testcase_60 | AC | 178 ms
23,844 KB |
testcase_61 | AC | 179 ms
23,848 KB |
testcase_62 | AC | 789 ms
24,504 KB |
testcase_63 | AC | 331 ms
23,984 KB |
testcase_64 | AC | 224 ms
23,984 KB |
testcase_65 | AC | 225 ms
24,104 KB |
testcase_66 | AC | 23 ms
24,120 KB |
testcase_67 | AC | 23 ms
23,876 KB |
testcase_68 | AC | 681 ms
24,508 KB |
testcase_69 | AC | 683 ms
24,380 KB |
testcase_70 | AC | 607 ms
24,504 KB |
testcase_71 | AC | 632 ms
24,624 KB |
testcase_72 | AC | 312 ms
21,936 KB |
testcase_73 | AC | 1,266 ms
25,020 KB |
testcase_74 | AC | 1,264 ms
25,016 KB |
testcase_75 | AC | 31 ms
24,252 KB |
testcase_76 | AC | 663 ms
24,344 KB |
testcase_77 | AC | 127 ms
23,976 KB |
testcase_78 | AC | 980 ms
24,764 KB |
testcase_79 | AC | 694 ms
26,288 KB |
testcase_80 | AC | 863 ms
24,780 KB |
testcase_81 | AC | 611 ms
24,252 KB |
testcase_82 | AC | 23 ms
22,068 KB |
testcase_83 | AC | 123 ms
25,888 KB |
testcase_84 | AC | 139 ms
23,980 KB |
testcase_85 | AC | 506 ms
24,196 KB |
testcase_86 | AC | 894 ms
24,884 KB |
testcase_87 | AC | 1,726 ms
25,244 KB |
testcase_88 | AC | 1,740 ms
25,276 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.IO; //using System.Text; //using System.Text.RegularExpressions; //using System.Globalization; //using System.Diagnostics; using static System.Console; //using System.Numerics; //using static System.Math; //using pair = Pair<int, int>; class Program { static void Main() { //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false }); new Program().solve(); Out.Flush(); } Scanner cin = new Scanner(); readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑ readonly int mod = 1000000007; void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; } void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; } void solve() { int N = cin.nextint; eratos(3 * N); var cnt = new long[2 * N]; long ans = 0; int b = 3; foreach (var c in prime) { if (c > N) break; if (c < 5) continue; foreach (var a in prime) { if (a == b) break; cnt[a + b]++; } foreach (var abc in prime) { int ab = abc - c; if (5 <= ab && ab < cnt.Length) { ans += cnt[ab]; } } b = c; } WriteLine(ans); } List<int> prime; bool[] is_prime; void eratos(int n) { prime = new List<int>(); is_prime = new bool[n + 1]; for (int i = 0; i <= n; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false; for (int i = 0; i <= n; i++) { if (is_prime[i]) { prime.Add(i); for (int j = 2 * i; j <= n; j += i) is_prime[j] = false; } } } int[] P; void phi(int n) { P = new int[n + 1]; for (int i = 0; i <= n; i++) P[i] = i; for (int i = 2; i <= n; i++) { if (is_prime[i]) { P[i] -= P[i] / i; for (int j = 2 * i; j <= n; j += i) P[j] -= P[j] / i; } } } } class Scanner { string[] s; int i; char[] cs = new char[] { ' ' }; public Scanner() { s = new string[0]; i = 0; } public string[] scan { get { return ReadLine().Split(); } } public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } } public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } } public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } } public string next { get { if (i < s.Length) return s[i++]; string st = ReadLine(); while (st == "") st = ReadLine(); s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries); i = 0; return next; } } public int nextint { get { return int.Parse(next); } } public long nextlong { get { return long.Parse(next); } } public double nextdouble { get { return double.Parse(next); } } }