submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s158169519
p00043
Java
import java.io.*; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int[] n=new int[10]; for(int i=0;i<13;i++){ n[(int)(line.charAt(i)-'1'+1)]++; } for(int i=1;i<=9;i++){ if(n[i]<2){ continue; } else{ n[i]-=2; if(check(n)){ System.out.println(i+" "); } } } System.out.println(""); } } private static boolean check(int[] n){ it min=0; for(int i=1;i<=9;i++){ n[i]%=3; } for(int i=1;i<=7;i++){ min=Math.min(n[i],n[i+1]); min=Math.min(min,n[i+2]); n[i]-=min; n[i+1]-=min; n[i+2]-=min; } for(int i=1;i<=9;i++){ if(n[i]!=0){ return false; } } return true; } }
Main.java:27: error: cannot find symbol it min=0; ^ symbol: class it location: class Main 1 error
s736547517
p00043
Java
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class AOJ0043 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String in; try { while ((in = sc.nextLine()) != null) { ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i = 1; i <= 9; i++) { String temp = new String(in) + i; if (solve(temp)) { ans.add(i); } } if (ans.size() == 0) { System.out.println(0); } else { Collections.sort(ans); for (int i = 0; i < ans.size() - 1; i++) { System.out.print(ans.get(i) + " "); } System.out.println(ans.get(ans.size() - 1)); } } } catch (Exception e) { } } static int[] toArray(String str) { int ret[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, }; for (char num : str.toCharArray()) { ret[num - '0' - 1]++; } for (int n : ret) { if (n > 4) return null; } return ret; } static boolean solve(String in) { for (int i = 0; i < 9; i++) { int temp1[] = toArray(in); if (temp1 == null) { return false; } if (head(temp1, i)) { int[] temp2 = temp1.clone(); if (solve2(temp2, 0)) { return true; } } } return false; } static boolean solve2(int[] in, int dep) { for (int i = 0; i < 9; i++) { int[] temp = in.clone(); if (kotu(temp, i)) { if (hantei(temp)) { return true; } if (dep < 4) { if (solve2(temp, dep + 1)) { return true; } } } } for (int i = 0; i < 7; i++) { int[] temp = in.clone(); if (shuntu(temp, i)) { if (hantei(temp)) { return true; } if (dep < 4) { if (solve2(temp, dep + 1)) { return true; } } } } return false; } // 頭をとる。取れたらtるえ static boolean head(int in[], int num) { if (in[num] >= 2) { in[num] -= 2; return true; } else { return false; } } // こーつをとる。取れたらtるえ static boolean kotu(int in[], int num) { if (in[num] >= 3) { in[num] -= 3; return true; } else { return false; } } // しゅんつをとる。取れたらtるえ static boolean shuntu(int in[], int num) { if (num > 7) { return false; } else { if (in[num] >= 1 && in[num + 1] >= 1 && in[num + 2] >= 1) { in[num]--; in[num + 1]--; in[num + 2]--; return true; } else { return false; } } } static boolean hantei(int[] in) { for (int n : in) { if (n != 0) return false; } return true; } }
Main.java:5: error: class AOJ0043 is public, should be declared in a file named AOJ0043.java public class AOJ0043 { ^ 1 error
s864140996
p00043
Java
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class AOJ0043 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String in; try { while ((in = sc.nextLine()) != null) { ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i = 1; i <= 9; i++) { String temp = new String(in) + i; if (solve(temp)) { ans.add(i); } } if (ans.size() == 0) { System.out.println(0); } else { Collections.sort(ans); for (int i = 0; i < ans.size() - 1; i++) { System.out.print(ans.get(i) + " "); } System.out.println(ans.get(ans.size() - 1)); } } } catch (Exception e) { } } static int[] toArray(String str) { int ret[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, }; for (char num : str.toCharArray()) { ret[num - '0' - 1]++; } for (int n : ret) { if (n > 4) return null; } return ret; } static boolean solve(String in) { for (int i = 0; i < 9; i++) { int temp1[] = toArray(in); if (temp1 == null) { return false; } if (head(temp1, i)) { int[] temp2 = temp1.clone(); if (solve2(temp2, 0)) { return true; } } } return false; } static boolean solve2(int[] in, int dep) { for (int i = 0; i < 9; i++) { int[] temp = in.clone(); if (kotu(temp, i)) { if (hantei(temp)) { return true; } if (dep < 4) { if (solve2(temp, dep + 1)) { return true; } } } } for (int i = 0; i < 7; i++) { int[] temp = in.clone(); if (shuntu(temp, i)) { if (hantei(temp)) { return true; } if (dep < 4) { if (solve2(temp, dep + 1)) { return true; } } } } return false; } // 頭をとる。取れたらtるえ static boolean head(int in[], int num) { if (in[num] >= 2) { in[num] -= 2; return true; } else { return false; } } // こーつをとる。取れたらtるえ static boolean kotu(int in[], int num) { if (in[num] >= 3) { in[num] -= 3; return true; } else { return false; } } // しゅんつをとる。取れたらtるえ static boolean shuntu(int in[], int num) { if (num > 7) { return false; } else { if (in[num] >= 1 && in[num + 1] >= 1 && in[num + 2] >= 1) { in[num]--; in[num + 1]--; in[num + 2]--; return true; } else { return false; } } } static boolean hantei(int[] in) { for (int n : in) { if (n != 0) return false; } return true; } }
Main.java:5: error: class AOJ0043 is public, should be declared in a file named AOJ0043.java public class AOJ0043 { ^ 1 error
s740416203
p00043
C
char t1[12]; int f(int x){ char t2[12]; int i,c=4; memcpy(t2,t1,12); t2[x]-=2; for(i=1;i<=9;){ if(t2[i]){ if(t2[i]>2)t2[i]-=3; else if(t2[i+1]&&t2[i+2]){ --t2[i];--t2[i+1];--t2[i+2]; } else return 0; if(!--c)return 1; } if(!t2[i])++i; } return 0; } int main(void){ char s[16]; int i,j,z; for(;fgets(s,16,stdin);){ memset(t1,0,12); for(z=i=0;i<13;)++t1[s[i++]-'0']; for(i=1;i<=9;i++){ if(t1[i]<4){ ++t1[i]; for(j=1;j<=9;j++){ if(t1[j]>1&&f(j)){ z++&&printf(" "); printf("%d",i,j); break; } } --t1[i]; } } puts(z?"":"0"); } return 0; }
main.c: In function 'f': main.c:6:9: error: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] 6 | memcpy(t2,t1,12); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy' +++ |+#include <string.h> 1 | char t1[12]; main.c:6:9: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch] 6 | memcpy(t2,t1,12); | ^~~~~~ main.c:6:9: note: include '<string.h>' or provide a declaration of 'memcpy' main.c: In function 'main': main.c:25:14: error: implicit declaration of function 'fgets' [-Wimplicit-function-declaration] 25 | for(;fgets(s,16,stdin);){ | ^~~~~ main.c:25:25: error: 'stdin' undeclared (first use in this function) 25 | for(;fgets(s,16,stdin);){ | ^~~~~ main.c:1:1: note: 'stdin' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' +++ |+#include <stdio.h> 1 | char t1[12]; main.c:25:25: note: each undeclared identifier is reported only once for each function it appears in 25 | for(;fgets(s,16,stdin);){ | ^~~~~ main.c:26:17: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 26 | memset(t1,0,12); | ^~~~~~ main.c:26:17: note: include '<string.h>' or provide a declaration of 'memset' main.c:26:17: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] main.c:26:17: note: include '<string.h>' or provide a declaration of 'memset' main.c:33:54: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 33 | z++&&printf(" "); | ^~~~~~ main.c:33:54: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:33:54: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:33:54: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:41:17: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 41 | puts(z?"":"0"); | ^~~~ main.c:41:17: note: include '<stdio.h>' or provide a declaration of 'puts'
s552006918
p00043
C
t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} } puts(z?"":"0"); } return 0; }
main.c:1:1: warning: data definition has no type or storage class 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~ main.c:1:1: error: type defaults to 'int' in declaration of 't1' [-Wimplicit-int] main.c:1:8: error: type defaults to 'int' in declaration of 't2' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~ main.c:1:15: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c:1:17: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c:1:19: error: type defaults to 'int' in declaration of 'k' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c:1:21: error: type defaults to 'int' in declaration of 'z' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c:1:23: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c:1:25: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c:1:27: error: return type defaults to 'int' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^ main.c: In function 'f': main.c:1:27: error: type of 'x' defaults to 'int' [-Wimplicit-int] main.c:1:40: error: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy' +++ |+#include <string.h> 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} main.c:1:40: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~~~~~ main.c:1:40: note: include '<string.h>' or provide a declaration of 'memcpy' main.c: At top level: main.c:1:174: error: return type defaults to 'int' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~~~ main.c: In function 'main': main.c:1:198: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} main.c:1:198: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~~~~ main.c:1:198: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:215: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 1 | t1[12],t2[12],i,j,k,z,c,r;f(x){r=0;c=4;memcpy(t2,t1,48);t2[x]-=2;for(k=1;k<=9;){t2[k]--?t2[k]>1?t2[k]-=2,r=!--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=!--c:0:0;t2[k]||++k;}}main(){char s[16];for(;~scanf(" %s",s);){memset(t1,0,48);for(z=i=0;i<13;)++t1[s[i++]-'0'];for(i=1;i<=9;i++){if(t1[i]<4){++t1[i];for(r=0,j=1;j<=9&&!r;j++,r=0){if(t1[j]>1&&(f(j),r)){z++&&putchar(32);print("%d",i);}}--t1[i];} | ^~~~~~ main.c:1:215: note: include '<string.h>' or provide a declaration of 'memset' main.c:1:215: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] main.c:1:215: note: include '<string.h>' or provide a declaration of 'memset' main.c:1:359: error: implicit
s349199598
p00043
C
t1[12],t2[12],i,j,k,z,r,c; f(x){ r=c=4; memcpy(t2,t1,48); t2[x]-=2; for(k=1;k<=9;){ t2[k]--?t2[k]>1?t2[k]-=2,r=--c:t2[k+1]&&t2[k+2]?--t2[k+1],--t2[k+2],r=--c:0:0; t2[k]<1&&++i; } main(){ char s[16]; for(;scanf(" %d",s);){ memset(t1,0,48); for(z=i=0;i<13;)++t1[s[i++]-'0']; for(i=1;i<=9;i++){ if(t1[i]<4){ ++t1[i]; for(r=j=1;r&&j<=9;j++){ if(t1[j]>1&&f(j)){ z++&&printf(32); printf("%d",i); break; } } --t1[i]; } } puts(z?"":"0"); } return 0; }
main.c:1:1: warning: data definition has no type or storage class 1 | t1[12],t2[12],i,j,k,z,r,c; | ^~ main.c:1:1: error: type defaults to 'int' in declaration of 't1' [-Wimplicit-int] main.c:1:8: error: type defaults to 'int' in declaration of 't2' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^~ main.c:1:15: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^ main.c:1:17: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^ main.c:1:19: error: type defaults to 'int' in declaration of 'k' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^ main.c:1:21: error: type defaults to 'int' in declaration of 'z' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^ main.c:1:23: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^ main.c:1:25: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 1 | t1[12],t2[12],i,j,k,z,r,c; | ^ main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int] 3 | f(x){ | ^ main.c: In function 'f': main.c:3:1: error: type of 'x' defaults to 'int' [-Wimplicit-int] main.c:5:9: error: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration] 5 | memcpy(t2,t1,48); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy' +++ |+#include <string.h> 1 | t1[12],t2[12],i,j,k,z,r,c; main.c:5:9: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch] 5 | memcpy(t2,t1,48); | ^~~~~~ main.c:5:9: note: include '<string.h>' or provide a declaration of 'memcpy' main.c:12:1: error: implicit declaration of function 'main' [-Wimplicit-function-declaration] 12 | main(){ | ^~~~ main.c:12:7: error: expected ';' before '{' token 12 | main(){ | ^ | ; main.c:33:1: error: expected declaration or statement at end of input 33 | } | ^
s246477432
p00043
C
#include <iostream> #include <vector> using namespace std; //#pragma comment(linker, "/STACK:400000000") #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<n;i++) #define pb push_back #define sz size() #define vi vector<int> string in; vi a; int dfs(vi v,int rest){ if(rest==0)return 1; if(rest==14){ rep(i,9)if(v[i]>=2){ vi w=v; w[i]-=2; if(dfs(w,12))return 1; } return 0; } rep(i,9)if(v[i]>=3){ vi w=v; w[i]-=3; if(dfs(w,rest-3))return 1; } rep(i,7)if(v[i] && v[i+1] && v[i+2]){ vi w=v; w[i]--; w[i+1]--; w[i+2]--; if(dfs(w,rest-3))return 1; } return 0; } int main(){ while(cin>>in){ vi v(9,0),ans; rep(i,13)v[in[i]-'1']++; rep(i,9){ if(v[i]==4)continue; vi w=v; w[i]++; if(dfs(w,14))ans.pb(i); } if(ans.sz==0)cout<<0<<endl; else{ rep(i,ans.sz)cout<<ans[i]+1<<( i!=ans.sz-1?" ":"\n"); } } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s818896451
p00043
C
#include<stdio.h> #include<string> #include<stdlib.h> int m[14],w[10],w2[10],a[9]; void f0(int *ws,int *k) { int j; for(j=1;ws[j]==0;j++); if(ws[j]>2) { ws[j]-=3; (*k)++; } } void f1(int *ws,int *k) { int j; for(j=1;j<8;) { if(ws[j]>0&&ws[j+1]>0&&ws[j+2]>0) { ws[j]--;ws[j+1]--;ws[j+2]--;(*k)++; } else j++; } } void f2(int *ws,int *k) { int j; for(j=1;j<=9;j++) if(ws[j]>=3) { ws[j]-=3; (*k)++; } } int s(int *ws) { int j,k=0; f0(ws,&k); f1(ws,&k); f2(ws,&k); return k; } int s2(int *ws) { int k=0; f0(ws,&k); f2(ws,&k); f1(ws,&k); return k; } int main() { int i,j,k,l,x; while(scanf("%1d",&m[0])==1) { for(i=1;i<13;i++) scanf("%1d",&m[i]); x=0; for(i=1;i<=9;i++) { for(l=1;l<=9;l++) { k=0; memset(w,0,sizeof(w)); for(j=0;j<13;j++) w[m[j]]++; if(w[i]+1>4) continue; w[i]++; if(w[l]<2) continue; w[l]-=2; memcpy(w2,w,sizeof(w)); if(s(w)==4||s2(w2)==4) { a[x++]=i; break; } } } if(x==0) printf("0\n"); else for(i=0;i<x;i++) printf("%d%s",a[i],i==x-1?"\n":" "); } return 0; }
main.c:2:9: fatal error: string: No such file or directory 2 | #include<string> | ^~~~~~~~ compilation terminated.
s573719275
p00043
C++
#include <iostream> #include <string> #include <string.h> #include <vector> #include <algorithm> #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define pb push_back using namespace std; int ans[10]; void solve(vector<int> a,int n) { int count = 0; rep(i,a.size()) count += a[i]; if(count == 0) { ans[n] = 1; return; } REP(i,1,10) { if(a[i] >= 3) { a[i] -= 3; solve(a,n); a[i] += 3; } } REP(i,3,10) { if(a[i-2] && a[i-1] && a[i]) { a[i-2]--; a[i-1]--; a[i]--; solve(a,n); a[i-2]++; a[i-1]++; a[i]++; } } } int main() { string s; while(cin >> s) { vector<int> a; memset(ans,0,sizeof(ans)); rep(i,10) a.pb(0); rep(i,s.size()) a[s[i] - '0']++; REP(i,1,10) { if(a[i] == 4) { continue; } else { a[i]++; REP(i,1,10) { if(a[j] >= 2) { a[j] -= 2; solve(a,i); a[j] += 2; } } a[i]--; } } bool count_0 = true; int ans_max = 0; REP(i,1,10) { if(ans[i]) { count_0 = false; ans_max = max(ans_max,i); } } if(count_0) { cout << 0 << endl; } else { bool flag = true; REP(i,1,10) { if(ans[i] == 1) { if(i == ans_max) { cout << i << endl; } else { cout << i << " "; } } } } } return 0; }
a.cc: In function 'int main()': a.cc:70:46: error: 'j' was not declared in this scope 70 | if(a[j] >= 2) | ^
s342548302
p00043
C++
#include <iostream> #include <string> #include <algorithm> #include <map> #include <vector> using namespace std; string str; bool c (map<char,int> m) { for (auto i = m.begin(); i != m.end(); i++) { if (i->second != 0) return false; } return true; } bool dfs(map<char,int> m) { if (c(m)) return true; for (char i = '1'; i <= '9'; i++) { if (m[i] >= 3) { m[i] -= 3; if (dfs (m)) return true;; m[i] += 3; } if (i + 2 <= '9' && m[i] > 0 && m[i+1] > 0 && m[i+2] > 0) { m[i]--; m[i + 1]--; m[i + 2]--; if (dfs(m)) return true; m[i]++; m[i + 1]++; m[i + 2]++; } } return false; } int main () { while (cin >> str) { map<char,int> m; for (char i = '1' ; i <= '9'; i++) m[i] = 0; for (int i = 0; i < str.size(); i++) { m[str[i]]++; } vector<char> res; for (char i = '1'; i <= '9'; i++) { if (m[i] >= 4) continue; m[i]++; for (char j = '1'; j <= '9'; j++) { if (m[j] >= 2) { m[j] -= 2; if (dfs(m)) { res.push_back(i); m[j] += 2; break; } m[j] += 2; } } m[i]--; } if (res.size()) { cout << res[0]; for (int i = 1; i < res.size(); i++) cout << " " << res[i]; else cout << 0; cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:63:9: error: expected '}' before 'else' 63 | else cout << 0; | ^~~~ a.cc:60:25: note: to match this '{' 60 | if (res.size()) { | ^
s761389682
p00043
C++
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <cmath> using namespace std; #define rep2(x,from,to) for(int x = (from); x < (to); ++(x)) #define rep(x,to) rep2(x,0,to) int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { int x; if(v1.size() > a) { x = v1[a]; n[x]--, n[x+1]--, n[x+2]--; } else { x = v2[a - v1.size()]; rep(j,3) n[x]--; } return n; } bool judge(int j, int k, int l, int m, vector<int> v1, vector<int> v2, int *n) { int nn[10]; rep(i,10) { nn[i] = n[i]; } minus(j,v1,v2, nn); minus(k,v1,v2, nn); minus(l,v1,v2, nn); minus(m,v1,v2, nn); bool f = 0; rep(i,10) { if(nn[i] < 0) { f = 0; break; } if(nn[i] == 2) f = 1; } if(f) return true; return false; } int main() { string s; while(cin >> s) { bool bl = 1; int n[10]; rep(i,10) { n[i] = 0; } rep(i,s.length()) { n[s[i] - '0']++; } rep2(i,1,10) { n[i]++; bool f = 0; rep(j,10) { if(n[j] > 4) f = 1; } if(f) { n[i]--; continue; } vector<int> v1; rep2(j,1,8) { int c = min(n[j],min(n[j+1], n[j+2])); if(c > 0) { rep(k,c) { v1.push_back(j); } } } vector<int> v2; rep2(j,1,10) { if(n[j] >= 3) v2.push_back(j); } int len = v1.size() + v2.size(); f = 0; rep(j,len) { rep2(k,j+1,len) { rep2(l,k+1,len) { rep2(m,l+1,len) { if(judge(j, k, l, m, v1, v2, n)) { bl = 0; if(i != 9) cout << i << " " ; else cout << i; f = 1; break; } } if(f) break; } if(f) break; } if(f) break; } n[i]--; } if(bl) cout << 0 << endl; else cout << endl; } return 0; }
a.cc: In function 'bool judge(int, int, int, int, std::vector<int>, std::vector<int>, int*)': a.cc:26:9: error: reference to 'minus' is ambiguous 26 | minus(j,v1,v2, nn); | ^~~~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~ a.cc:27:9: error: reference to 'minus' is ambiguous 27 | minus(k,v1,v2, nn); | ^~~~~ /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~ a.cc:28:9: error: reference to 'minus' is ambiguous 28 | minus(l,v1,v2, nn); | ^~~~~ /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~ a.cc:29:9: error: reference to 'minus' is ambiguous 29 | minus(m,v1,v2, nn); | ^~~~~ /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~
s853072910
p00043
C++
#include <iostream> #include <cstdio> #include <string> #include <vector> using namespace std; #define rep2(x,from,to) for(int x = (from); x < (to); ++(x)) #define rep(x,to) rep2(x,0,to) int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { int x; if(v1.size() > a) { x = v1[a]; n[x]--, n[x+1]--, n[x+2]--; } else { x = v2[a - v1.size()]; rep(j,3) n[x]--; } return n; } bool judge(int j, int k, int l, int m, vector<int> v1, vector<int> v2, int *n) { int nn[10]; rep(i,10) { nn[i] = n[i]; } minus(j,v1,v2, nn); minus(k,v1,v2, nn); minus(l,v1,v2, nn); minus(m,v1,v2, nn); bool f = 0; rep(i,10) { if(nn[i] < 0) { f = 0; break; } if(nn[i] == 2) f = 1; } if(f) return true; return false; } int main() { string s; while(cin >> s) { bool bl = 1; int n[10]; rep(i,10) { n[i] = 0; } rep(i,s.length()) { n[s[i] - '0']++; } rep2(i,1,10) { n[i]++; bool f = 0; rep(j,10) { if(n[j] > 4) f = 1; } if(f) { n[i]--; continue; } vector<int> v1; rep2(j,1,8) { int c = min(n[j],min(n[j+1], n[j+2])); if(c > 0) { rep(k,c) { v1.push_back(j); } } } vector<int> v2; rep2(j,1,10) { if(n[j] >= 3) v2.push_back(j); } int len = v1.size() + v2.size(); f = 0; rep(j,len) { rep2(k,j+1,len) { rep2(l,k+1,len) { rep2(m,l+1,len) { if(judge(j, k, l, m, v1, v2, n)) { bl = 0; if(i != 9) cout << i << " " ; else cout << i; f = 1; break; } } if(f) break; } if(f) break; } if(f) break; } n[i]--; } if(bl) cout << 0 << endl; else cout << endl; } return 0; }
a.cc: In function 'bool judge(int, int, int, int, std::vector<int>, std::vector<int>, int*)': a.cc:26:9: error: reference to 'minus' is ambiguous 26 | minus(j,v1,v2, nn); | ^~~~~ In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~ a.cc:27:9: error: reference to 'minus' is ambiguous 27 | minus(k,v1,v2, nn); | ^~~~~ /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~ a.cc:28:9: error: reference to 'minus' is ambiguous 28 | minus(l,v1,v2, nn); | ^~~~~ /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~ a.cc:29:9: error: reference to 'minus' is ambiguous 29 | minus(m,v1,v2, nn); | ^~~~~ /usr/include/c++/14/bits/stl_function.h:163:12: note: candidates are: 'template<class _Tp> struct std::minus' 163 | struct minus; | ^~~~~ a.cc:9:6: note: 'int* minus(int, std::vector<int>, std::vector<int>, int (&)[10])' 9 | int* minus(int a, vector<int> v1, vector<int> v2, int (&n)[10]) { | ^~~~~
s279982909
p00043
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; int tmp[10]; bool solve(int n, int f) { bool judge = false; if (f == 4) { for (int i = 1; i < 10; i++) { if (tmp[i] == 2) { return true; } } return false; } if (tmp[n] >= 3) { tmp[n] -= 3; judge = solve(n, f + 1); tmp[n] += 3; } if (n <= 7 && tmp[n] >= 1 && tmp[n + 1] >= 1 && tmp[n + 2] >= 1) { tmp[n]--; tmp[n + 1]--; tmp[n + 2]--; judge = solve(n, f + 1); tmp[n]++; tmp[n + 1]++; tmp[n + 2]++; } if (n < 9) { judge = solve(n + 1, f); } return judge; } int main() { string source; int pai[10]; while (getline(cin, source)) { fill(pai[0], pai[10], 0); for (int i = 0; i < 13; i++) { pai[source[i] - '0']++; } vector<int> v; for (int i = 1; i < 10; i++) { if (pai[i] < 4) { pai[i]++; for (int j = 1; j < 10; j++) { tmp[j] = pai[j]; } if (solve(1, 0)) { v.push_back(i); } pai[i]--; } } if (v.empty()) cout << 0 << endl; else { for (int i = 0; i < v.size() - 1; i++) { cout << v[i] << ' '; } cout << v[v.size() - 1] << endl; } } return 0; }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]': /usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int; _Tp = int]' 998 | { std::__fill_a1(__first, __last, __value); } | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int; _Tp = int]' 1029 | std::__fill_a(__first, __last, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:42:7: required from here 42 | fill(pai[0], pai[10], 0); | ~~~~^~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:952:9: error: invalid type argument of unary '*' (have 'int') 952 | *__first = __tmp; | ^~~~~~~~
s266204472
p00043
C++
#include <bits/stdc++.h> using namespace std; using db = double; using ll = long long; using vi = vector <int>; #define op operator #define pb push_back const int N = 15; int c[N]; bool ans; void dfs(int a, int b) { if(!a && !b) { ans = 1; return; } int i = find_if(c, c + N, [](int i) { return i > 0; }) - c; if(a) { if(c[i] >= 3) { c[i] -= 3; dfs(a - 1, b); c[i] += 3; } if(c[i] && c[i + 1] && c[i + 2]) { c[i] --; c[i + 1] --; c[i + 2] --; dfs(a - 1, b); c[i] ++; c[i + 1] ++; c[i + 2] ++; } } if(b && c[i] >= 2) { c[i] -= 2; dfs(a, b - 1); c[i] += 2; } } int main() { ios :: sync_with_stdio(0); for(string s; cin >> s; ) { memset(c, 0, sizeof c); for(char i : s) c[i - '0'] ++; vector <int> v; for(int i = 1; i <= 9; i ++) if(c[i] < 4) { c[i] ++; ans = 0; dfs(4, 1); if(ans) v.pb(i); c[i] --; } if(v.size() == 0) cout << "0\n"; else { for(int i = 0; i < v.size(); i ++) cout << x << (i + 1 == v.size() ? '\n' : ' '); cout << '\n'; } } return 0; }
a.cc: In function 'int main()': a.cc:59:41: error: 'x' was not declared in this scope 59 | cout << x << (i + 1 == v.size() ? '\n' : ' '); | ^
s067440631
p00043
C++
#include<iostream> using namespace std; const int MAX_LINELEN = 14; const int DIGIT_NUM = 10; int puzzleCheck(int [], int, int, int *); void checkNum(char *, int []); int main(void) { while( true ){ int i; int isThisLineClear = 0; char lineData[MAX_LINELEN] = ""; scanf("%s", lineData); if( strlen( lineData ) < 13){ break; } for(i = 1; i <= DIGIT_NUM; i++){ int j; int foundFlag = 0; int invalidPuzzle = 0; int num[DIGIT_NUM] = {0,}; lineData[MAX_LINELEN - 1] = i + '0'; checkNum(lineData, num); for(j = 0; j < DIGIT_NUM; j++){ if(num[j] >= 5){ invalidPuzzle = 1; } } if(invalidPuzzle){continue;} puzzleCheck(num, i, 0, &foundFlag); if(foundFlag){isThisLineClear = 1;} } if(isThisLineClear){ printf("\b\n"); }else{ printf("0\n"); } } return 0; } int puzzleCheck(int num[], int nowNumber, int twoPairFlag, int *foundFlag) { int isComplete = 0; for(int i = 0; i < DIGIT_NUM; i++){ if(num[i] == 0){ isComplete++; } } if(isComplete == DIGIT_NUM && *foundFlag == 0){ printf("%d ", nowNumber); *foundFlag = 1; } for(int i = 0; i < DIGIT_NUM; i++){ if(num[i] >= 2 && twoPairFlag == 0){ num[i] -= 2; puzzleCheck(num, nowNumber, 1, foundFlag); num[i] += 2; } if(num[i] >= 3){ num[i] -= 3; puzzleCheck(num, nowNumber, twoPairFlag, foundFlag); num[i] += 3; } if(i <= DIGIT_NUM - 3){ if(num[i] >= 1 && num[i+1] >= 1 && num[i+2] >= 1){ num[i]--;num[i+1]--;num[i+2]--; puzzleCheck(num, nowNumber, twoPairFlag, foundFlag); num[i]++;num[i+1]++;num[i+2]++; } } } return 0; } void checkNum(char *lineData, int num[]) { const char digits[DIGIT_NUM] = "123456789"; for(unsigned int i = 0; i < strlen(lineData); i++){ for(int j = 0; j < DIGIT_NUM; j++){ if(lineData[i] == digits[j]){ num[j]++; } } } }
a.cc: In function 'int main()': a.cc:19:21: error: 'strlen' was not declared in this scope 19 | if( strlen( lineData ) < 13){ | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | a.cc: In function 'void checkNum(char*, int*)': a.cc:90:37: error: 'strlen' was not declared in this scope 90 | for(unsigned int i = 0; i < strlen(lineData); i++){ | ^~~~~~ a.cc:90:37: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s039763106
p00043
C++
#include<iostream> #include<string> #include<cstdio> #include<algorithm> #include<vector> using namespace std; int x[14]; bool r[14][100]; bool tempai(int num, int jan, int chou, bool make){ for(int i=0; i<14; i++){ if(!r[i][num]){ if(jan == 1 && i<13){ if(x[i] == x[i+1] && !(r[i+1][num])){ for(int j=0; j<14; j++){r[j][num+1] = r[j][num];} r[i][num+1] = 1; r[i+1][num+1] = 1; make = tempai(num+1,0,chou,make); } } if(chou>0 && i<12){ if(x[i] == x[i+1] && x[i+1] == x[i+2]&& !(r[i+1][num]) && !(r[i+2][num])){ for(int j=0; j<14; j++){r[j][num+1] = r[j][num];} r[i][num+1] = 1; r[i+1][num+1] = 1; r[i+2][num+1] = 1; make = tempai(num+1,jan,chou-1,make); } } if(chou>0 && x[i]<8){ int a = -1,b = -1; for(int j=i+1; j<14; j++){ if(x[j] == x[i]+1 && !(r[j][num])){a = j;} if(x[j] == x[i]+2 && !(r[j][num])){b = j;} } if(a!=-1 && b!=-1){ for(int j=0; j<14; j++){r[j][num+1] = r[j][num];} r[i][num+1] = 1; r[a][num+1] = 1; r[b][num+1] = 1; make = tempai(num+1,jan,chou-1,make); } } } } if(!(jan) && !(chou)){make = true;} return make; } int main(){ for(;;){ int hai[14] = {0}; vector<int> ans; for(int i=0; i<13; i++){ if(scanf("%1d",&hai[i]) == EOF){break;} } for(int i=1; i<10; i++){ hai[13] = i; for(int j=0; j<14; j++){x[j] = hai[j];} sort(x,x+14); for(int j=0,r=-1,cou=0; j<14; j++){ if(r != x[j]){r = x[j];cou = 1;} else{cou++;} if(cou > 4){goto jump;} } bool f = tempai(0,1,4,false); if(f){ans.push_back(i);} jump:; } if(ans.empty()){cout<<"0"<<endl;} else{ for(int i=0; i<ans.size(); i++){ if(!i){cout<<ans[i];} else{cout<<" "<<ans[i];} } cout <<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:66:5: error: jump to label 'jump' 66 | jump:; | ^~~~ a.cc:62:26: note: from here 62 | if(cou > 4){goto jump;} | ^~~~ a.cc:64:12: note: crosses initialization of 'bool f' 64 | bool f = tempai(0,1,4,false); | ^
s788981116
p00043
C++
import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner in = new Scanner(System.in); while(in.hasNext()) { String str=in.next(); int a[]=new int[10]; for(int i=0;i<str.length();i++) a[str.charAt(i)-'0']++; int ans[]=new int[10]; for(int i=1;i<=9;i++) { if(a[i]==4) continue; a[i]++; for(int j=1 ; j <= 9 ; j++ ) { if( a[j] >= 2 ) { a[j] -= 2; sol(a,i,ans); a[j] += 2; } } a[i]--; } int j=0; for(int i=1;i<=9;i++) { if(ans[i]==1) { if(j!=0) System.out.print(" "); System.out.print(i); j=1; } } if(j==0) System.out.print(0); System.out.println(); } } public static void sol(int a[],int n,int ans[]) { int s=0; for(int i=1;i<=9;i++) s+=a[i]; if(s==0) ans[n]=1; for(int i=1; i <= 9 ; i++ ) { if( a[i] >= 3 ) { a[i] -= 3; sol( a , n , ans ); a[i] += 3; } } for(int i=1 ; i <= 7 ; i++ ) { if(a[i]>=1&&a[i+1]>=1&&a[i+2]>=1) { a[i]--; a[i+1]--; a[i+2]--; sol( a , n , ans ); a[i]++; a[i+1]++; a[i+2]++; } } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: expected unqualified-id before 'public' 2 | public class Main | ^~~~~~
s802952253
p00043
C++
#include <stdio.h> #include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it) bool judgeTriple(int tmp2[], int count){ if(count==4) return true; for(int i=1; i<=7; i++){ if(tmp2[i]>=1 && tmp2[i+1]>=1 && tmp2[i+2]>=1){ tmp2[i]--; tmp2[i+1]--; tmp2[i+2]--; if(judgeTriple(tmp2,count+1)) return true; tmp2[i]++; tmp2[i+1]++; tmp2[i+2]++; } } REP(i,10){ if(tmp2[i]>=3){ tmp2[i]-=3; if(judgeTriple(tmp2,count+1)) return true; tmp2[i]+=3; } } return false; } bool isEnd(int tmp[]){ REP(i,10){ if(tmp[i]>=5) return false; } // remove head for(int i=1; i<10; i++){ if(tmp[i]>=2){ tmp[i]-=2; if( judgeTriple(tmp,0) ) return true; tmp[i]+=2; } } return false; } int main() { string str; while(cin>>str){ int nums[10]; memset(nums, 0, sizeof(nums)); REP(i,str.size()) nums[str[i]-'0']++; vector<int> res; for(int i=1; i<=9; i++){ int tmp[10]; memcpy(tmp, nums, sizeof(nums)); tmp[i]++; if(isEnd(tmp)){ res.push_back(i); } } if(res.empty()) cout << "0" << endl; else{ bool first=true; IREP(it,res){ if(!first) cout << " "; first = false; cout << *it; } cout << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:59:5: error: 'memset' was not declared in this scope 59 | memset(nums, 0, sizeof(nums)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <vector> +++ |+#include <cstring> 6 | using namespace std; a.cc:68:7: error: 'memcpy' was not declared in this scope 68 | memcpy(tmp, nums, sizeof(nums)); | ^~~~~~ a.cc:68:7: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s546984054
p00043
C++
#include <stdio.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <map> #include <vector> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it) bool judgeTriple(int tmp2[], int count){ if(count==4) return true; for(int i=1; i<=7; i++){ if(tmp2[i]>=1 && tmp2[i+1]>=1 && tmp2[i+2]>=1){ tmp2[i]--; tmp2[i+1]--; tmp2[i+2]--; if(judgeTriple(tmp2,count+1)) return true; tmp2[i]++; tmp2[i+1]++; tmp2[i+2]++; } } REP(i,10){ if(tmp2[i]>=3){ tmp2[i]-=3; if(judgeTriple(tmp2,count+1)) return true; tmp2[i]+=3; } } return false; } bool isEnd(int tmp[]){ REP(i,10){ if(tmp[i]>=5) return false; } // remove head for(int i=1; i<10; i++){ if(tmp[i]>=2){ tmp[i]-=2; if( judgeTriple(tmp,0) ) return true; tmp[i]+=2; } } return false; } int main() { string str; while(cin>>str){ int nums[10]; memset(nums, 0, sizeof(nums)); REP(i,str.size()) nums[str[i]-'0']++; vector<int> res; for(int i=1; i<=9; i++){ int tmp[10]; memcpy(tmp, nums, sizeof(nums)); tmp[i]++; if(isEnd(tmp)){ res.push_back(i); } } if(res.empty()) cout << "0" << endl; else{ bool first=true; IREP(it,res){ if(!first) cout << " "; first = false; cout << *it; } cout << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:60:5: error: 'memset' was not declared in this scope 60 | memset(nums, 0, sizeof(nums)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <vector> +++ |+#include <cstring> 7 | using namespace std; a.cc:69:7: error: 'memcpy' was not declared in this scope 69 | memcpy(tmp, nums, sizeof(nums)); | ^~~~~~ a.cc:69:7: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s699432685
p00043
C++
#include<cstring> #include<vector> using namespace std; bool slove(int tmp[]) { for(int i=1;i<10;i++) { while(tmp[i]!=0) { if(tmp[i]>=3) { tmp[i]-=3; // cout<<i<<":3set"<<endl; } else if(i<8&&tmp[i]>0&&tmp[i+1]>0&&tmp[i+2]>0) { tmp[i]--; tmp[i+1]--; tmp[i+2]--; // cout<<i<<":3zyun"<<endl; } else { return false; } } } return true; } int main() { string str; for(;cin>>str;) { int data[10]; memset(data,0,sizeof(data)); for(int i=0;i<str.size();i++) { data[str[i]-'0']++; } for(int i=0;i<10;i++) { } vector<int> ans; // int tmp1[10]; // memcpy(tmp1, data, sizeof(data)); for(int i=1;i<10;i++) { if(data[i]>3) continue; // cout<<i<<":add"<<endl; for(int j=1;j<10;j++) { int tmp[10]; memcpy(tmp, data, sizeof(tmp)); tmp[i]++; if(tmp[j]>1) { /* for(int xx=1;xx<10;xx++) for(int yy=tmp[xx];yy>0;yy--) cout<<xx; cout<<endl; */ tmp[j]-=2; // cout<<j<<":head"<<endl; if(slove(tmp)) { ans.push_back(i); j=10; } } } } for(int i=0;i<ans.size();i++) { cout<<ans[i]; if(i==ans.size()-1) cout<<endl; else cout<<" "; } if(ans.size()<1) cout<<0<<endl; } }
a.cc: In function 'int main()': a.cc:36:3: error: 'string' was not declared in this scope 36 | string str; | ^~~~~~ a.cc:3:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' 2 | #include<vector> +++ |+#include <string> 3 | a.cc:37:8: error: 'cin' was not declared in this scope 37 | for(;cin>>str;) | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<vector> +++ |+#include <iostream> 3 | a.cc:37:13: error: 'str' was not declared in this scope; did you mean 'std'? 37 | for(;cin>>str;) | ^~~ | std a.cc:84:15: error: 'cout' was not declared in this scope 84 | cout<<ans[i]; | ^~~~ a.cc:84:15: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:86:23: error: 'endl' was not declared in this scope 86 | cout<<endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include<vector> +++ |+#include <ostream> 3 | a.cc:91:3: error: 'cout' was not declared in this scope 91 | cout<<0<<endl; | ^~~~ a.cc:91:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:91:12: error: 'endl' was not declared in this scope 91 | cout<<0<<endl; | ^~~~ a.cc:91:12: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s957801320
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.mth.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=new BigInteger(a); System.out.print(x.nextProbablePrime()+" "+prevProbablePrime(a)); } } private static int prevProbablePrime(int a){ a--; while(true){ BigInteger y=new BigInteger(a); if(y.isProbablePrime(16)){ return a; } a--; } } }
Main.java:4: error: package java.mth does not exist import java.mth.BigInteger; ^ Main.java:12: error: cannot find symbol BigInteger x=new BigInteger(a); ^ symbol: class BigInteger location: class Main Main.java:12: error: cannot find symbol BigInteger x=new BigInteger(a); ^ symbol: class BigInteger location: class Main Main.java:19: error: cannot find symbol BigInteger y=new BigInteger(a); ^ symbol: class BigInteger location: class Main Main.java:19: error: cannot find symbol BigInteger y=new BigInteger(a); ^ symbol: class BigInteger location: class Main 5 errors
s285627452
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=new BigInteger(a); System.out.print(x.nextProbablePrime()+" "+prevProbablePrime(a)); } } private static int prevProbablePrime(int a){ a--; while(true){ BigInteger y=new BigInteger(a); if(y.isProbablePrime(16)){ return a; } a--; } } }
Main.java:12: error: no suitable constructor found for BigInteger(int) BigInteger x=new BigInteger(a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; int cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; int cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; int cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Main.java:19: error: no suitable constructor found for BigInteger(int) BigInteger y=new BigInteger(a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; int cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; int cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; int cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 2 errors
s409723069
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=new BigInteger(a); System.out.print(x.nextProbablePrime()+" "+prevProbablePrime(a)); } } public static int prevProbablePrime(int a){ a--; while(true){ BigInteger y=new BigInteger(a); if(y.isProbablePrime(16)){ return a; } a--; } } }
Main.java:12: error: no suitable constructor found for BigInteger(int) BigInteger x=new BigInteger(a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; int cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; int cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; int cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Main.java:19: error: no suitable constructor found for BigInteger(int) BigInteger y=new BigInteger(a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; int cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; int cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; int cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 2 errors
s238570078
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=new BigInteger(a); System.out.println(x.nextProbablePrime()+" "+prevProbablePrime(a)); } } public static int prevProbablePrime(int a){ a--; while(true){ BigInteger y=new BigInteger(a); if(y.isProbablePrime(16)){ return a; } a--; } } }
Main.java:12: error: no suitable constructor found for BigInteger(int) BigInteger x=new BigInteger(a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; int cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; int cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; int cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Main.java:19: error: no suitable constructor found for BigInteger(int) BigInteger y=new BigInteger(a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; int cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; int cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; int cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 2 errors
s371812297
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=new BigInteger((long)a); System.out.println(x.nextProbablePrime()+" "+prevProbablePrime(a)); } } public static int prevProbablePrime(int a){ a--; while(true){ BigInteger y=new BigInteger((long)a); if(y.isProbablePrime(16)){ return a; } a--; } } }
Main.java:12: error: no suitable constructor found for BigInteger(long) BigInteger x=new BigInteger((long)a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; long cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; long cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; long cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Main.java:19: error: no suitable constructor found for BigInteger(long) BigInteger y=new BigInteger((long)a); ^ constructor BigInteger.BigInteger(byte[]) is not applicable (argument mismatch; long cannot be converted to byte[]) constructor BigInteger.BigInteger(int[]) is not applicable (argument mismatch; long cannot be converted to int[]) constructor BigInteger.BigInteger(String) is not applicable (argument mismatch; long cannot be converted to String) constructor BigInteger.BigInteger(long) is not applicable (BigInteger(long) has private access in BigInteger) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 2 errors
s531277101
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=BigInteger.valueOf(a); System.out.println(prevProbablePrime(a)+" "+x.nextProbablePrime()); } } public static int prevProbablePrime(int a){ a--; while(true){ BigInteger y=BigInteger.valueOf(a); if(y.isProbablePrime()){ return a; } a--; } } }
Main.java:20: error: method isProbablePrime in class BigInteger cannot be applied to given types; if(y.isProbablePrime()){ ^ required: int found: no arguments reason: actual and formal argument lists differ in length 1 error
s502856937
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null){ int a=Integer.parseInt(line); BigInteger x=BigInteger.valueOf(a); System.out.println(prevProbablePrime(a)+" "+x.nextProbablePrime()); } } public static int prevProbablePrime(int a){ BigInteger y=BigInteger.valueOf(a); y=y.subtract(BigInteger.valueOf("1")); while(true){ if(y.isProbablePrime(1)){ return a; } y=y.subtract(BigInteger.valueOf("1")); } } }
Main.java:18: error: no suitable method found for valueOf(String) y=y.subtract(BigInteger.valueOf("1")); ^ method BigInteger.valueOf(long) is not applicable (argument mismatch; String cannot be converted to long) method BigInteger.valueOf(int[]) is not applicable (argument mismatch; String cannot be converted to int[]) Main.java:23: error: no suitable method found for valueOf(String) y=y.subtract(BigInteger.valueOf("1")); ^ method BigInteger.valueOf(long) is not applicable (argument mismatch; String cannot be converted to long) method BigInteger.valueOf(int[]) is not applicable (argument mismatch; String cannot be converted to int[]) 2 errors
s450951047
p00044
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class PrimeNumber2_0044 { public static void main(String[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> inputList = new ArrayList<>(50); try { while (input.ready()) { inputList.add(Integer.valueOf(input.readLine())); } } catch (IOException e) { e.printStackTrace(); } for (int num : inputList) { System.out.println(getLowerPrimeNumber(num) + " " + getHigherPrimeNumber(num)); } } private static int getLowerPrimeNumber(int number) { for (int i = number - 1; i > 3; i--) { if (isPrimeNumber(i)) { return i; } } return 2; } private static int getHigherPrimeNumber(int number) { for (int i = number + 1; i < Integer.MAX_VALUE; i++) { if (isPrimeNumber(i)) { return i; } } return 2; } public static ArrayList<Integer> getPrimeNumberList(int maxNumber) { ArrayList<Integer> primeNumberList = new ArrayList<>(); primeNumberList.add(2); primeNumberList.add(3); primeNumberList.add(5); primeNumberList.add(7); int[] oneDigitList = { 1, 3, 7, 9 }; int tmp; int sqrtTmp; boolean addFlag; for (int i = 10; i <= maxNumber; i += 10) { for (int oneDigit : oneDigitList) { addFlag = true; tmp = i + oneDigit; sqrtTmp = (int) Math.sqrt(tmp); for (int primeNumber : primeNumberList) { if (tmp % primeNumber == 0) { addFlag = false; break; } if (sqrtTmp < primeNumber) { break; } } if (addFlag) { primeNumberList.add(tmp); } } } return primeNumberList; } private static boolean isPrimeNumber(int number) { if (number % 2 == 0) { return false; } final int limit = (int) Math.sqrt(number); for (int i = 3; i <= limit; i++) { if (number % i == 0) return false; } return true; } }
Main.java:7: error: class PrimeNumber2_0044 is public, should be declared in a file named PrimeNumber2_0044.java public class PrimeNumber2_0044 ^ 1 error
s097266884
p00044
Java
import java.util.*; import static java.util.Arrays.*; import static java.lang.Math.*; public class Main { void run(){ Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int n =sc.nextInt(); int min, max; for(max=p-1;!isP(max);max--); for(min=p+1;!isP(min);min++); System.out.println(max + " " + min); } } boolean isP(int p) { for(int i=2;i*i<=p;i++) if(p%i == 0) return false; return true; } public static void main (String[] args ) { new Main().run(); } }
Main.java:11: error: cannot find symbol for(max=p-1;!isP(max);max--); ^ symbol: variable p location: class Main Main.java:12: error: cannot find symbol for(min=p+1;!isP(min);min++); ^ symbol: variable p location: class Main 2 errors
s636016509
p00044
Java
import java.util.Scanner; public class Proc{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int[] v = new int[25025]; for(int i = 0;i < 25025;i++){ v[i] = 1; } int p = 3; while(true){ if(p*p > 50050){ break; }else{ if(v[(p-1)/2] == 0){ p += 2; }else{ int t = p*p; while(t < 50050){ v[(t-1)/2] = 0; t += 2*p; } p += 2; } } } while(scan.hasNext()){ int n = scan.nextInt(); if(n == 3){ System.out.println(2 + " " + 5); continue; } int prev = 0; boolean sw = false; for(int i = 1;i < 25025;i++){ if(v[i] != 1){ continue; } if((2*i + 1) == n && !sw){ sw = true; continue; } if(sw || (2*i + 1) > n){ System.out.println(2*prev+1 + " " + (2*i+1)); break; } prev = i; } } } }
Main.java:3: error: class Proc is public, should be declared in a file named Proc.java public class Proc{ ^ 1 error
s476427521
p00044
Java
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; class Main { static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws Exception{ int N = 50022; int[] primes = new int[N]; for (int i=0; i<N; i++) { if (i == 0 || i == 1) primes[i] = 0; else primes[i] = 1; } for (int i=2; i<N/2; i++) { if (primes[i] == 0) continue; for (int j=i*2; j<N; j+=i) { primes[j] = 0; } } HashMap<Integer, Integer> iidx = new HashMap<Integer, Integer>(); int[] prime_seq = new int[N]; int j = 0; for (int i=0; i<N; i++) { if (primes[i] == 1) { prime_seq[j] = i; iidx.put(i, j); j++; } } String row = ""; while ((row = reader.readLine()) != null) { if(row.isEmpty()) return; int n = Integer.parseInt(row); int in = iidx.get(n); System.out.println(prime_seq[in-1] + " " + prime_seq[in+1])
Main.java:42: error: reached end of file while parsing System.out.println(prime_seq[in-1] + " " + prime_seq[in+1]) ^ 1 error
s657082387
p00044
C
#include<stdio.h> #define M 51000 int main(){ int i,j,p[M]={1,1}; for(i=2;i*i<M;i++){ if(p[i])continue; for(j=i*i;j<M;j+=i)p[j]=1; } while(~scanf("%d",&i)){ for(j=i-1;p[j];j--x); printf("%d ",j); for(j=i+1;p[j];j++); printf("%d\n",j); } return 0; }
main.c: In function 'main': main.c:10:23: error: expected ')' before 'x' 10 | for(j=i-1;p[j];j--x); | ~ ^ | )
s929890607
p00044
C
#include<stdio.h> int main(void){ int n, i, k, key1, key2, s[100000], l; for ( i = 1; i <= 100000; i++ ) { s[i] = 0; } for ( k = 2; k <= 100000; k++ ){ if (s[k] == 0) { for ( l = 2; l <= 100000 / k; l++ ) { s[k * l] = 1; } } } while ( scanf("%d", &n) != EOF ) { for ( i = n - 1; i > 2; i-- ) { if( s[i] == 0 ){ key1 = i; break; } } for ( i = n + 1; i < 100000; i++){ if( s[i] == 0 ){ key2 = i; break; } } printf("%d %d\n", key1, key2); } return 0;
main.c: In function 'main': main.c:29:4: error: expected declaration or statement at end of input 29 | return 0; | ^~~~~~
s546221507
p00044
C
int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;}
main.c: In function 'main': main.c:1:32: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} main.c:1:32: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} | ^~~~~ main.c:1:32: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:48: error: 'EOF' undeclared (first use in this function) 1 | int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} | ^~~ main.c:1:48: note: 'EOF' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' main.c:1:48: note: each undeclared identifier is reported only once for each function it appears in main.c:1:127: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} | ^~~~~~ main.c:1:127: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:127: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:127: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:235: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 1 | int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} | ^~~~~~ main.c:1:235: note: include '<stdio.h>' or provide a declaration of 'printf'
s700258941
p00044
C
#include <stdio.h>int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;}
main.c:1:19: warning: extra tokens at end of #include directive 1 | #include <stdio.h>int j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;} | ^~~ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s776475014
p00044
C
#include <stdio.h> #define DATANUM 60000 int maxarray(int va[], int std1); int minarray(int vb[], int std2); int main(void) { int num[DATANUM] = {0}; int i, j, std; num[0] = 1; num[1] = 1; for(i = 2; i < DATANUM; i++) { if(i != 2 && i % 2 == 0) num[i] = 1; if(i != 3 && i % 3 == 0) num[i] = 1; if(i != 5 && i % 5 == 0) num[i] = 1; if(i != 7 && i % 7 == 0) num[i] = 1; for(j = 2; j < i; j++) { if(!(i % j)) { num[i] = 1; break; } } } while(scanf("%d", &std) != EOF) { printf("%d %d\n", maxarray(num, std), minarray(num, std)); } return(0); } int maxarray(int va[], int std1) { int max, i; max = 2; for(i = 2; i < std1; i++) { if(i > max && va[i] != 1) { max = i; } } return(max); } int minarray(int vb[], int std2) { int min, i, count = 0; for(i = std2 + 1; i < DATANUM; i++) { if(vb[i] != 1 && count == 0) { min = i; count++; } } return(min); } ; i < DATANUM; i++) { if(vb[i] != 1 && count == 0) { min = i; count++; } } return(min); }
main.c:61:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 61 | ; i < DATANUM; i++) { | ^ main.c:61:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 61 | ; i < DATANUM; i++) { | ^~ main.c:68:5: error: expected identifier or '(' before 'return' 68 | return(min); | ^~~~~~ main.c:69:1: error: expected identifier or '(' before '}' token 69 | } | ^
s330575561
p00044
C
#include<iostream> #include<cstdio> int main() { int a[50001]={0}; int i,j; int n,c; a[2]=1; for(i=3;i<=50001;i+=2){ if(a[i]==2) continue; else if(a[i]==0){ a[i]=1; for(j=i*2;j<=50001;j+=i) a[j]=2; } } while(scanf("%d",&n)!=EOF){ for(i=n-1;i>1;i--){ if(a[i]==1){ printf("%d ",i); break; } } for(i=n+1;i<=50001;i++) if(a[i]==1){ printf("%d\n",i); break; } } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s606471436
p00044
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #define PI 3.14159265358979323 //void quick(int *,long long,long long); int main(){ int a,i,j,flag; char s[60000]; for(i=2;i<60000;i++) s[i]=1; i=2; while(i*i<60000){ j=i; while(i*j<60000){ s[i*j]=0; j++; } i++; while(s[i]==0) i++; } while(scanf("%d",&a)!=EOF){ for(i=a-1;s[i]==0;i--); printf("%d ",i); for(i=a+1;s[i]==0;i++); printf("%d\n",i); } } /*void qu
main.c:32:1: error: unterminated comment 32 | /*void qu | ^
s005518363
p00044
C++
#include <iostream> #include <algorithm> #include <math.h> using namespace std; bool isPrime(int num); int main(){ int n; while(cin >> n, n){ int prev = 0, next = 0; for(int i = num-2; i >= 3; i -= 2){ if(isPrime(i))( prev = i; break; } } for(int i = num+2; i <= 50000; i += 2){ if(isPrime(i){ next = i; break; } } cout << prev << " " << next << endl; } return 0; } bool isPrime(int num){ if(num < 2) return false; for(int i = 2; i*i <= num; i++){ if(num % i == 0) return false; } return true; }
a.cc: In function 'int main()': a.cc:13:29: error: 'num' was not declared in this scope; did you mean 'enum'? 13 | for(int i = num-2; i >= 3; i -= 2){ | ^~~ | enum a.cc:15:41: error: expected ')' before ';' token 15 | prev = i; | ^ | ) a.cc:14:39: note: to match this '(' 14 | if(isPrime(i))( | ^ a.cc:20:29: error: 'num' was not declared in this scope; did you mean 'enum'? 20 | for(int i = num+2; i <= 50000; i += 2){ | ^~~ | enum a.cc:21:38: error: expected ')' before '{' token 21 | if(isPrime(i){ | ~ ^ | ) a.cc:25:17: error: expected primary-expression before '}' token 25 | } | ^ a.cc:27:22: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>') 27 | cout << prev << " " << next << endl; | ~~~~~^~~~~~~ In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) |
s324164893
p00044
C++
#include<iostream> using namespace std; int main(){ int table[80000]={}; for(int i=2; i*i80000; ++i){ if(!table[i]){ for(int j=i*2; j<=80000; j+=i){ table[j]=1; } } } int n; while(cin >> n,n){ int i; for(i=n-1; table[i]; --i); cout << i << " "; for(i=n+1; table[i]; ++i); cout << i << endl; } return 0; }
a.cc: In function 'int main()': a.cc:6:18: error: 'i80000' was not declared in this scope 6 | for(int i=2; i*i80000; ++i){ | ^~~~~~
s421442959
p00044
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ int ans_ma; int ma_n = n + 1; int c_ma = 0; if(ma_n % 2 == 0){ ++ma_n; } for(int i = ma_n; ;i = i + 2){ int q = sqrt(i); if(q < 3){ ans_ma = q; break; } else{ c_ma = 1; for(int j = 3;j <= q;j = j + 2){ if(i % j == 0){ c_ma = 0; break; } } if(c_ma == 1){ ans_ma = i; break; } } } int ans_mi; int mi_n = n - 1; int c_mi = 0; if(mi_n == 2){ ans_mi = 2; } else{ if(mi_n % 2 == 0){ --mi_n; } for(int i = mi_n;i => 3;i = i - 2){ int q = sqrt(i); if(q < 3){ ans_mi = q; break; } else{ c_mi = 1; for(int j = 3;j <= q;j = j + 2){ if(i % j == 0){ c_mi = 0; break; } } if(c_mi == 1){ ans_mi = i; break; } } } } cout<<ans_mi<<" "<<ans_ma<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:51:27: error: expected primary-expression before '>' token 51 | for(int i = mi_n;i => 3;i = i - 2){ | ^
s214720145
p00044
C++
const int MAX_NUM = 100000000; bool prime_number[MAX_NUM]; void prime_create() { fill(prime_number, prime_number + MAX_NUM, true); prime_number[0] = prime_number[1] = false; for(int i = 2; i < MAX_NUM; i++) { if(prime_number[i]) for(int j = 2; i*j < MAX_NUM; j++) { prime_number[i*j] = false; } } }
a.cc: In function 'void prime_create()': a.cc:5:5: error: 'fill' was not declared in this scope 5 | fill(prime_number, prime_number + MAX_NUM, true); | ^~~~
s324493588
p00044
C++
const int MAX_NUM = 100000000; bool prime_number[MAX_NUM]; void prime_create() { fill(prime_number, prime_number + MAX_NUM, true); prime_number[0] = prime_number[1] = false; for(int i = 2; i < MAX_NUM; i++) { if(prime_number[i]) for(int j = 2; i*j < MAX_NUM; j++) { prime_number[i*j] = false; } } }
a.cc: In function 'void prime_create()': a.cc:5:5: error: 'fill' was not declared in this scope 5 | fill(prime_number, prime_number + MAX_NUM, true); | ^~~~
s509959633
p00044
C++
19 3517
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 19 | ^~
s601231541
p00044
C++
def create_prime(n): prime = [1] * (n + 1) prime[:2] = [0, 0] for i in range(len(prime)): if prime[i]: for j in range(2 * i, len(prime), i): prime[j] = 0 return prime def under(prime, n): for i in range(n - 1, -1, -1): if prime[i]: return i def over(prime, n): for i in range(n + 1, len(prime)): if prime[i]: return i import sys n = [int(line) for line in sys.stdin] prime = create_prime(max(n) + 100) for ni in n: print(under(prime, ni), over(prime, ni))
a.cc:1:1: error: 'def' does not name a type 1 | def create_prime(n): | ^~~
s953910277
p00044
C++
require 'prime' while str=gets s=str.to_i low = -((1-s)..(-3)).find{|i| (i).prime? } high = ((s+1)..50000).find{|i| i.prime? } puts "#{low} #{high}" end
a.cc:1:9: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 1 | require 'prime' | ^~~~~~~ a.cc:1:1: error: 'require' does not name a type 1 | require 'prime' | ^~~~~~~ a.cc:5:5: error: 'high' does not name a type 5 | high = ((s+1)..50000).find{|i| i.prime? } | ^~~~ a.cc:6:5: error: 'puts' does not name a type 6 | puts "#{low} #{high}" | ^~~~
s464372116
p00044
C++
#include <iostream> using namespace std; /*テァツエツ?ヲツ閉ーテ・ツ按、テ・ツョツ?/ const int MAX = 1000100; bool prime[MAX]; void sieve(){ fill(prime, prime+MAX, true); prime[0] = prime[1] = false; for(int i=2; i*i < MAX; i++){ if(!prime[i]) continue; for(int j=i*i; j < MAX; j += i) prime[j] = false; } } int main(){ int n; sieve(); while(cin >> n){ for(int i=1; ; i++) if(prime[n-i]){ cout << n-i << " "; break;} for(int i=1; ; i++) if(prime[n+i]){ cout << n-i << endl; break;} } }
a.cc:5:1: error: unterminated comment 5 | /*テァツエツ?ヲツ閉ーテ・ツ按、テ・ツョツ?/ | ^
s097108153
p00044
C++
#include <iostream> using namespace std; /*テァツエツ?ヲツ閉ーテ・ツ按、テ・ツョツ?/ const int MAX = 1000100; bool prime[MAX]; void sieve(){ fill(prime, prime+MAX, true); prime[0] = prime[1] = false; for(int i=2; i*i < MAX; i++){ if(!prime[i]) continue; for(int j=i*i; j < MAX; j += i) prime[j] = false; } } int main(){ int n; sieve(); while(cin >> n){ for(int i=1; ; i++) if(prime[n-i]){ cout << n-i << " "; break;} for(int i=1; ; i++) if(prime[n+i]){ cout << n+i << endl; break;} } }
a.cc:5:1: error: unterminated comment 5 | /*テァツエツ?ヲツ閉ーテ・ツ按、テ・ツョツ?/ | ^
s979397878
p00044
C++
#include<vector> #include<cmath> #include<map> #include<cstdio> using namespace std; #define rep(i,a) for(int i = 0 ; i < a; i ++) #define loop(i,b,a) for(int i = b ; i < a; i ++) const int MAX = 50000; bool p[MAX]; void isPrime(){ fill(p,p + MAX,true); p[0] = p[1] = false; rep(i,MAX){ if(p[i]){ for(int j = i + i ; j < MAX ; j += i) p[j] = false; } } } int main(void){ isPrime(); int n; while(cin>>n){ int i; for(i = n-1 ; !p[i] ; i --); cout<<i<<" "; for(i = n+1 ; !p[i] ; i ++); cout<<i<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:9: error: 'cin' was not declared in this scope 25 | while(cin>>n){ | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include<cstdio> +++ |+#include <iostream> 6 | using namespace std; a.cc:30:5: error: 'cout' was not declared in this scope 30 | cout<<i<<" "; | ^~~~ a.cc:30:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:32:14: error: 'endl' was not declared in this scope 32 | cout<<i<<endl; | ^~~~ a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 5 | #include<cstdio> +++ |+#include <ostream> 6 | using namespace std;
s757409437
p00044
C++
#include<iostream> using namespace std; #define rep(i,a) for(int i = 0 ; i < a ; i ++) #define loop(i,a,b) for(int i = a ; i < b ; i ++) const int M = (1e6); int p[M]; void isPrime(){ rep(i,M)p[i] = true; p[0] = p[1] = false; loop(i,2,M){ if(p[i]) for(int j = i + i ; j < M ; j += i) p[j] = false; } } int main(void){ isPrime(); int n; while(cin>>n){ int i = n - 1; while(!prime[i]);cout<<i<<" "; i = n + 1; while(!prime[i]);cout<<i<<endl; } }
a.cc: In function 'int main()': a.cc:21:12: error: 'prime' was not declared in this scope 21 | while(!prime[i]);cout<<i<<" "; | ^~~~~ a.cc:23:12: error: 'prime' was not declared in this scope 23 | while(!prime[i]);cout<<i<<endl; | ^~~~~
s514248716
p00044
C++
#include<iostream> using namespace std; #define rep(i,a) for(int i = 0 ; i < a ; i ++) #define loop(i,a,b) for(int i = a ; i < b ; i ++) const int M = (1e6); int p[M]; void isPrime(){ rep(i,M)p[i] = true; p[0] = p[1] = false; loop(i,2,M){ if(p[i]) for(int j = i + i ; j < M ; j += i) p[j] = false; } } int main(void){ isPrime(); int n; while(cin>>n){ int i = n - 1; while(!prime[i]);cout<<i<<" "; i = n + 1; while(!prime[i]);cout<<i<<endl; } }
a.cc: In function 'int main()': a.cc:21:12: error: 'prime' was not declared in this scope 21 | while(!prime[i]);cout<<i<<" "; | ^~~~~ a.cc:23:12: error: 'prime' was not declared in this scope 23 | while(!prime[i]);cout<<i<<endl; | ^~~~~
s458696823
p00044
C++
#include<iostream> using namespace std; #define rep(i,a) for(int i = 0 ; i < a ; i ++) #define loop(i,a,b) for(int i = a ; i < b ; i ++) const int M = (1e6); int p[M]; void isPrime(){ rep(i,M)p[i] = true; p[0] = p[1] = false; loop(i,2,M){ if(p[i]) for(int j = i + i ; j < M ; j += i) p[j] = false; } } int main(void){ isPrime(); int n; while(cin>>n){ int i = n - 1; while(!prime[i]);cout<<i<<" "; i = n + 1; while(!prime[i]);cout<<i<<endl; } }
a.cc: In function 'int main()': a.cc:21:12: error: 'prime' was not declared in this scope 21 | while(!prime[i]);cout<<i<<" "; | ^~~~~ a.cc:23:12: error: 'prime' was not declared in this scope 23 | while(!prime[i]);cout<<i<<endl; | ^~~~~
s404707126
p00044
C++
#include<iostream> using namespace std; #define rep(i,a) for(int i = 0 ; i < a ; i ++) #define loop(i,a,b) for(int i = a ; i < b ; i ++) const int M = (1e6); int p[M]; void isPrime(){ rep(i,M)p[i] = true; p[0] = p[1] = false; loop(i,2,M){ if(p[i]) for(int j = i + i ; j < M ; j += i) p[j] = false; } } int main(void){ isPrime(); int n; while(cin>>n){ int i = n - 1; while(!prime[i]);cout<<i<<" "; i = n + 1; while(!prime[i]);cout<<i<<endl; } }
a.cc: In function 'int main()': a.cc:21:12: error: 'prime' was not declared in this scope 21 | while(!prime[i]);cout<<i<<" "; | ^~~~~ a.cc:23:12: error: 'prime' was not declared in this scope 23 | while(!prime[i]);cout<<i<<endl; | ^~~~~
s083560169
p00044
C++
#include<iostream> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (scanf_s("%d",&n) != EOF) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc: In function 'int main()': a.cc:9:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 9 | while (scanf_s("%d",&n) != EOF) { | ^~~~~~~ | scanf a.cc: In function 'int primemax(int)': a.cc:18:38: error: 'sqrt' was not declared in this scope 18 | for (int j = sqrt(i)+1;; j--) { | ^~~~ a.cc: In function 'int primemin(int)': a.cc:31:46: error: 'sqrt' was not declared in this scope 31 | for (int j = sqrt(i)+1; ; j--) { | ^~~~
s013562903
p00044
C++
#include<iostream> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (scanf("%d",&n) != EOF) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc: In function 'int primemax(int)': a.cc:18:38: error: 'sqrt' was not declared in this scope 18 | for (int j = sqrt(i)+1;; j--) { | ^~~~ a.cc: In function 'int primemin(int)': a.cc:31:46: error: 'sqrt' was not declared in this scope 31 | for (int j = sqrt(i)+1; ; j--) { | ^~~~
s087006919
p00044
C++
#include<iostream> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (cin << n) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc: In function 'int main()': a.cc:9:20: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 9 | while (cin << n) { | ~~~ ^~ ~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:9:20: note: candidate: 'operator<<(int, int)' (built-in) 9 | while (cin << n) { | ~~~~^~~~ a.cc:9:20: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:9:16: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 9 | while (cin << n) { | ^~~ In file included from /usr/include/c++/14/bits/ios_base.h:46: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)' 671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)' 684 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:684:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)' 689 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:689:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:810:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ /usr/include/c++/14/ostream:810:5: note: template argument deduction/substitution failed: /usr/include/c++/14/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_istream<char>&; _Tp = int]': a.cc:9:16: required from here 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:810:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ a.cc: In function 'int primemax(int)': a.cc:18:38: error: 'sqrt' was not declared in this scope 18 | for (int j = sqrt(i)+1;; j--) { |
s865437231
p00044
C++
#include<iostream> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (cin << n) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc: In function 'int main()': a.cc:9:20: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 9 | while (cin << n) { | ~~~ ^~ ~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:9:20: note: candidate: 'operator<<(int, int)' (built-in) 9 | while (cin << n) { | ~~~~^~~~ a.cc:9:20: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:9:16: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 9 | while (cin << n) { | ^~~ In file included from /usr/include/c++/14/bits/ios_base.h:46: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)' 671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)' 684 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:684:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)' 689 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:689:5: note: template argument deduction/substitution failed: a.cc:9:23: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:810:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ /usr/include/c++/14/ostream:810:5: note: template argument deduction/substitution failed: /usr/include/c++/14/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_istream<char>&; _Tp = int]': a.cc:9:16: required from here 9 | while (cin << n) { | ^ /usr/include/c++/14/ostream:810:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ a.cc: In function 'int primemax(int)': a.cc:18:38: error: 'sqrt' was not declared in this scope 18 | for (int j = sqrt(i)+1;; j--) { |
s239503319
p00044
C++
#include<iostream> #include<math> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (scanf("%d",&n) != EOF) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc:2:9: fatal error: math: No such file or directory 2 | #include<math> | ^~~~~~ compilation terminated.
s315928264
p00044
C++
#include<iostream> #include<math> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (cin >> n) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc:2:9: fatal error: math: No such file or directory 2 | #include<math> | ^~~~~~ compilation terminated.
s196954626
p00044
C++
#include<iostream> #include<stdio.h> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (scanf("%d",&n) != EOF) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int m) { int result = 0; while (true) { for (int i = m; ; i--) { for (int j = sqrt(i)+1;; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } } int primemin(int m) { int result = 0; while (1) { for (int i = m; ; i++) { for (int j = sqrt(i)+1; ; j--) { if ((i%j)==0)break; if (j == 2) { result = i; return result; } } } } }
a.cc: In function 'int primemax(int)': a.cc:19:38: error: 'sqrt' was not declared in this scope 19 | for (int j = sqrt(i)+1;; j--) { | ^~~~ a.cc: In function 'int primemin(int)': a.cc:32:46: error: 'sqrt' was not declared in this scope 32 | for (int j = sqrt(i)+1; ; j--) { | ^~~~
s140749107
p00044
C++
#include<iostream> #include<stdio.h> using namespace std; int primemax(int m); int primemin(int m); int main() { int n; while (scanf_s("%d",&n) != EOF) { cout << primemax(n - 1) << " " << primemin(n + 1) << endl; } } int primemax(int n) { int t; for (n;; n--) { for (t = 2; t <= n; t++) { if (t == n) { return n; } else if (n%t == 0) { break; } } } } int primemin(int n) { int t; for (n;; n++) { for (t = 2; t <= n; t++) { if (t == n) { return t; } else if (n%t == 0) { break; } } } }
a.cc: In function 'int main()': a.cc:10:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 10 | while (scanf_s("%d",&n) != EOF) { | ^~~~~~~ | scanf
s921383747
p00044
C++
#include <iostream> #include <string> #include <vector> #include <cstring> #include <climits> #include <algorithm> #include <map> using namespace std; bool is_prime(int p) { for (int i=2; i*i<=p; i++) { if (p % i == 0) return false; } return true; } int main() { int N; while (cin >> N) { for (int p1=N-1; ; p1--) { if (is_prime(p1)) break; } for (int p2=N+1; ; p2++) { if (is_prime(p2)) break; } cout << p1 << " " << p2 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: 'p1' was not declared in this scope 27 | cout << p1 << " " << p2 << endl; | ^~ a.cc:27:30: error: 'p2' was not declared in this scope 27 | cout << p1 << " " << p2 << endl; | ^~
s129706944
p00044
C++
#include <iostream> #include <string> #include <vector> #include <cstring> #include <climits> #include <algorithm> #include <map> using namespace std; bool is_prime(int p) { for (int i=2; i*i<=p; i++) { if (p % i == 0) return false; } return true; } int main() { int N; while (cin >> N) { for (int p1=N-1; ; p1--) { if (is_prime(p1)) break; } for (int p2=N+1; ; p2++) { if (is_prime(p2)) break; } cout << p1 << " " << p2 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: 'p1' was not declared in this scope 27 | cout << p1 << " " << p2 << endl; | ^~ a.cc:27:30: error: 'p2' was not declared in this scope 27 | cout << p1 << " " << p2 << endl; | ^~
s313742950
p00044
C++
asdf
a.cc:1:1: error: 'asdf' does not name a type 1 | asdf | ^~~~
s439286632
p00044
C++
from itertools import takewhile, dropwhile pn, tmp = [], [i for i in range(2, 50000)] while tmp[0] < 224: v = tmp.pop(0) pn.append(v) tmp = list(filter(lambda x: x%v!=0, tmp)) for t in tmp: pn.append(t) while True: try: n = int(input()) except: break print(list(takewhile(lambda x: x<n, pn))[-1], list(dropwhile(lambda x: x<=n, pn))[0])
a.cc:1:1: error: 'from' does not name a type 1 | from itertools import takewhile, dropwhile | ^~~~
s112676915
p00044
C++
#include<iostream> using namespace std; bool isprime(int n) { if (n == 2)return true; if (n % 2 == 0)return false; for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false; return true; } int main() { int n; while (cin >> n){ for (int i = n - 1; ; i--){ if (isprime(i)) { cout << i << ' '; break; } } for (int i = n + 1;; i++) { if (isprime(i)) { cout << i << endl; break; } } } return 0; }
a.cc: In function 'bool isprime(int)': a.cc:6:30: error: 'sqrt' was not declared in this scope 6 | for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false; | ^~~~
s255876770
p00044
C++
#include <iostream>; using namespace std; int a[100000]; void sosuu() { a[0] = 2; int k, z = 1; for (int i = 3; i<100000; i++) { k = 0; for (int j = 0; a[j] <= sqrt(i); j++) { if (i%a[j] == 0) { k++; break; } } if (k == 0) { a[z] = i; z++; } } } int nibun(int n, int s, int e){ if (s >= e) return s; if(a[(s + e)/2] < n){ if(a[(s+e)/2 + 1]>n ){ return (s + e) / 2; } return nibun(n, (s + e) / 2 + 1, e); } else if(a[(s + e) / 2] > n){ return nibun(n, s, (s + e) / 2 - 1); } else return (s + e) / 2; } int main(){ sosuu(); int n, k; while(cin >> n){ int ret = nibun(n, 0, 10000); if(n == a[ret]){ cout << a[ret - 1] << " " << a[ret + 1] << endl; } else cout << a[ret] << " " << a[ret + 1] << endl; } return 0; }
a.cc:1:20: warning: extra tokens at end of #include directive 1 | #include <iostream>; | ^ a.cc: In function 'void sosuu()': a.cc:11:41: error: 'sqrt' was not declared in this scope 11 | for (int j = 0; a[j] <= sqrt(i); j++) { | ^~~~
s864026603
p00044
C++
#include <iostream>; using namespace std; int a[100000]; void sosuu() { a[0] = 2; int k, z = 1; for (int i = 3; i<100000; i++) { k = 0; for (int j = 0; a[j] <= sqrt(i); j++) { if (i%a[j] == 0) { k++; break; } } if (k == 0) { a[z] = i; z++; } } return; } int nibun(int n, int s, int e){ if (s >= e) return s; if(a[(s + e)/2] < n){ if(a[(s+e)/2 + 1]>n ){ return (s + e) / 2; } return nibun(n, (s + e) / 2 + 1, e); } else if(a[(s + e) / 2] > n){ return nibun(n, s, (s + e) / 2 - 1); } else return (s + e) / 2; } int main(){ sosuu(); int n, k; while(cin >> n){ int ret = nibun(n, 0, 10000); if(n == a[ret]){ cout << a[ret - 1] << " " << a[ret + 1] << endl; } else cout << a[ret] << " " << a[ret + 1] << endl; } return 0; }
a.cc:1:20: warning: extra tokens at end of #include directive 1 | #include <iostream>; | ^ a.cc: In function 'void sosuu()': a.cc:11:41: error: 'sqrt' was not declared in this scope 11 | for (int j = 0; a[j] <= sqrt(i); j++) { | ^~~~
s305481159
p00044
C++
#include <iostream>; using namespace std; int a[100000]; void sosuu() { a[0] = 2; int k, z = 1; for (int i = 3; i<100000; i++) { k = 0; for (int j = 0; a[j] <= sqrt(i); j++) { if (i%a[j] == 0) { k++; break; } } if (k == 0) { a[z] = i; z++; } } return; } int nibun(int n, int s, int e){ if (s >= e) return s; if(a[(s + e)/2] < n){ if(a[(s+e)/2 + 1]>n ){ return (s + e) / 2; } return nibun(n, (s + e) / 2 + 1, e); } else if(a[(s + e) / 2] > n){ return nibun(n, s, (s + e) / 2 - 1); } else return (s + e) / 2; } int main(){ sosuu(); int n, k; while(cin >> n){ int ret = nibun(n, 0, 10000); if(n == a[ret]){ cout << a[ret - 1] << " " << a[ret + 1] << endl; } else cout << a[ret] << " " << a[ret + 1] << endl; } return 0; }
a.cc:1:20: warning: extra tokens at end of #include directive 1 | #include <iostream>; | ^ a.cc: In function 'void sosuu()': a.cc:11:41: error: 'sqrt' was not declared in this scope 11 | for (int j = 0; a[j] <= sqrt(i); j++) { | ^~~~
s991484159
p00044
C++
#include <iostream> using namespace std; int prime[60000]; void sieve(){ memset(prime, 1, sizeof prime); int i; for(i = 2;i*i <= 60000;i++){ if(prime[i]){ for(int j = 2;i*j <= 60000;j++){ prime[i*j] = 0; } } } } int main(){ int n; sieve(); while (cin >> n){ for(int i = n-1;;i--){ if(prime[i]){ cout << i << ' ' << prime[i] << endl; break; } } for(int i = n+1;;i++){ if(prime[i]){ cout << i << ' ' << prime[i] << endl; break; } } cout << prime[n] << endl; } return 0; }
a.cc: In function 'void sieve()': a.cc:9:9: error: 'memset' was not declared in this scope 9 | memset(prime, 1, sizeof prime); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s628830083
p00044
C++
MAX = 60000 lst = [i for i in range(MAX)] lst[0] = lst[1] = 0 for i in range(MAX): if lst[i] != 0: for j in range(i * 2, MAX, i): lst[j] = 0 while 0 == 0: try: n = int(input()) i = n - 1 j = n + 1 while lst[i] == 0: i -= 1 while lst[j] == 0: j += 1 print(lst[i],lst[j]) except EOFError: break
a.cc:1:1: error: 'MAX' does not name a type 1 | MAX = 60000 | ^~~
s738432022
p00044
C++
#include<iostream> using namespace std; int main() { bool prime[55001] = { false }; for (int i = 2; i <= sqrt(55000); i++) { if (!prime[i]) { for (int j = 2; i*j <= 55000; j++) { prime[i*j] = true; } } } int n; while (cin >> n) { for (int i = n-1;; i--) { if (!prime[i]) { cout << i << " "; break; } } for (int i = n+1;; i++) { if (!prime[i]) { cout << i << endl; break; } } } }
a.cc: In function 'int main()': a.cc:6:30: error: 'sqrt' was not declared in this scope 6 | for (int i = 2; i <= sqrt(55000); i++) { | ^~~~
s730501093
p00044
C++
#include<iostream> #include<vector> #define MAX 1000000 using namespace std; int main(){ vector<bool> v(MAX); for(int i = 0;i<MAX;i++) v[i]=true; v[0]=v[1]=false; for(int i = 2;i<1000;i++){ if(v[i]){ for(int j=i*i;j<MAX;j+=i){ v[j]=false; } } } while(true){ int a; cin >> a; if(cin.eof())return 0; while(i=n-1){ if(v[i]){ cout >>i>>' '; break; } i--; } while(i=n+1){ if(v[i]){ cout >>i>>endl; break; } i++; } }
a.cc: In function 'int main()': a.cc:22:13: error: 'i' was not declared in this scope 22 | while(i=n-1){ | ^ a.cc:22:15: error: 'n' was not declared in this scope 22 | while(i=n-1){ | ^ a.cc:29:11: error: 'i' was not declared in this scope 29 | while(i=n+1){ | ^ a.cc:29:13: error: 'n' was not declared in this scope 29 | while(i=n+1){ | ^ a.cc:36:2: error: expected '}' at end of input 36 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s586562742
p00044
C++
#include <iostream> using namespace std; #define N 50000 int main(){ int n; bool is_prime[N]; is_prime[0] = is_prime[1] = false; for(int i=2; i<N;i++){ is_prime[i] = true; } for(int i=2; i*i<N; i++){ if(is_prime[i]){ for(int j=i*i;j<N; j+=i){ is_prime[j] = false; } } } while(1){ int counter = 0; cin >> n; if(n == 0) break; if(cin.eof()) break; int i=0; while(i <= n/2){ if(is_prime[n-i] && is_prime[n]) counter++; i++; } cout << counter << endl; } retrurn 0; }
a.cc: In function 'int main()': a.cc:39:7: error: 'retrurn' was not declared in this scope 39 | retrurn 0; | ^~~~~~~
s019179862
p00044
C++
#include <iostream> using namespace std; int main(){ bool is_prime[50001]; is_prime[0]=is_prime[1]=false; for(int i=2;i<50001;i++){ is_prime[i] = true; } for(int i=2;i*i<50001;i++){ if(is_prime[i]){ for(int j=i*i;j<50001;j=j+i){ is_prime[j] = false; } } } int n_prime[50001]; int cnt = 0; for(int i=0;i<50001;i++){<50001 if(is_prime[i]){ cnt++; } n_prime[i] = cnt; } while(true){ int n; cin >> n; if(cin.eof()) break; int high,low; for(int i=0;i<50001;i++){ if((is_prime[i]) && (n_prime[i] == n_prime[n]-1)){ low = i; } if((is_prime[i]) && (n_prime[i] == n_prime[n]+1)){ high = i; } } cout << low << " " << high << endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:28: error: expected primary-expression before '<' token 23 | for(int i=0;i<50001;i++){<50001 | ^
s697192308
p00044
C++
#include<iostream> #include<vector> int main() { std::vector<bool>is_prime(50020, true); const int root = static_cast<int>(floor(sqrt(50021))); for (int i = 0; i <= root - 2; i++) { if (is_prime[i]) { for (int j = i + 2; (i + 2) * j < 50021; j++) { is_prime[(i + 2) * j - 2] = false; } } } for (int n; std::cin >> n;) { for (int i = n - 2 - 1;; i--) { if (is_prime[i]) { std::cout << i + 2 << ' '; break; } } for (int i = n - 2 + 1;; i++) { if (is_prime[i]) { std::cout << i + 2 << std::endl; break; } } } return 0; }
a.cc: In function 'int main()': a.cc:6:49: error: 'sqrt' was not declared in this scope 6 | const int root = static_cast<int>(floor(sqrt(50021))); | ^~~~ a.cc:6:43: error: 'floor' was not declared in this scope 6 | const int root = static_cast<int>(floor(sqrt(50021))); | ^~~~~
s705542412
p00044
C++
j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} x=0;} r:; }return 0;}
a.cc:1:1: error: 'j' does not name a type 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^ a.cc: In function 'int main()': a.cc:1:40: error: 'n' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^ a.cc:1:28: error: 'scanf' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^~~~~ a.cc:1:44: error: 'EOF' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^~~ a.cc:1:1: note: 'EOF' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} a.cc:1:53: error: 'i' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^ a.cc:1:69: error: 'j' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^ a.cc:1:109: error: 'x' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^ a.cc:1:119: error: 'x' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^ a.cc:1:126: error: 'printf' was not declared in this scope 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^~~~~~ a.cc:1:126: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' a.cc:2:1: error: 'x' was not declared in this scope 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^ a.cc:2:12: error: 'i' was not declared in this scope 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^ a.cc:2:28: error: 'j' was not declared in this scope 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^ a.cc:2:69: error: 'x' was not declared in this scope 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^ a.cc:2:79: error: 'x' was not declared in this scope 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^ a.cc:2:86: error: 'printf' was not declared in this scope 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^~~~~~ a.cc:2:86: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' a.cc:3:1: error: 'x' was not declared in this scope 3 | x=0;} r:; }return 0;} | ^ a.cc:1:148: error: label 'qq' used but not defined 1 | j,i,n,x=0;int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto qq;} | ^~ a.cc:2:109: error: label 'rr' used but not defined 2 | x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto rr;} | ^~
s755678997
p00044
C++
#include <iostream> using namespace std; #define MAX 1000000 int prime[MAX]; void is_prime(){ for(int i = 0 ; i < MAX ; i++) prime[i] = 1; prime[0] = prime[1] = 0; for(int i = 2 ; i*i < MAX ; i++){ if(prime[i] = 1){ for(int j = 2*i ; j < MAX ; j += i){ prime[j] = 0; } } } } int main(void){ int n; is_prime(); while(cin >> n){ for(int i = n-1 ; prime[i] == 0 ; i--); cout << i << ' '; for(int i = n+1 ; prime[i] == 0 ; i++); cout << i << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:13: error: 'i' was not declared in this scope 27 | cout << i << ' '; | ^
s928295153
p00044
C++
#include <iostream> using namespace std; #define MAX 1000000 int prime[MAX]; void is_prime(){ for(int i = 0 ; i < MAX ; i++) prime[i] = 1; prime[0] = prime[1] = 0; for(int i = 2 ; i*i < MAX ; i++){ if(prime[i] = 1){ for(int j = 2*i ; j < MAX ; j += i){ prime[j] = 0; } } } } int main(void){ int n; is_prime(); while(cin >> n){ for(int i = n - 1 ; prime[i] == 0 ; i--); cout << i << ' '; for(int j = n + 1 ; prime[j] == 0 ; j++); cout << j << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:13: error: 'i' was not declared in this scope 27 | cout << i << ' '; | ^ a.cc:30:13: error: 'j' was not declared in this scope 30 | cout << j << endl; | ^
s279658143
p00044
C++
#include <iostream> using namespace std; #define MAX 50100 int main(void){ bool prime[MAX] = false; prime[0] = prime[1] = true; for(int i = 2 ; i*i <= MAX-1 ; i++){ if(!prime[i]){ for(int j = i*2 ; j <= MAX - 1 ; j += i){ prime[j] = true; } } } int n; while(cin >> n){ for(int i = n-1 ; ; i--){ if(!prime[i]){ cout << i << ' '; break; } } for(int i = n+1 ; ; i++){ if(!prime[i]){ cout << i << endl; break; } } } return 0; }
a.cc: In function 'int main()': a.cc:6:21: error: array must be initialized with a brace-enclosed initializer 6 | bool prime[MAX] = false; | ^~~~~
s728912614
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Program { static void Main(string[] args) { var primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } var number = int.Parse(input); var previousPrimeNumber = 0; var nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); } } public static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:49:15: error: expected ':' before 'static' 49 | public static bool IsPrime(int number) | ^~~~~~~ | : a.cc:75:6: error: expected ';' after class definition 75 | } | ^ | ; a.cc: In static member function 'static void _0044::Program::Main(int*)': a.cc:10:13: error: 'var' was not declared in this scope 10 | var primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:21: error: expected ';' before 'input' 21 | var input = Console.ReadLine(); | ^~~~~ a.cc:23:21: error: 'string' was not declared in this scope 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:23:42: error: 'input' was not declared in this scope; did you mean 'int'? 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:21: error: expected ';' before 'number' 25 | var number = int.Parse(input); | ^~~~~~ a.cc:26:21: error: expected ';' before 'previousPrimeNumber' 26 | var previousPrimeNumber = 0; | ^~~~~~~~~~~~~~~~~~~ a.cc:27:21: error: expected ';' before 'nextPrimeNumber' 27 | var nextPrimeNumber = 0; | ^~~~~~~~~~~~~~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc:45:44: error: 'previousPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~~~~~ a.cc:45:65: error: 'nextPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~ a.cc: In static member function 'static bool _0044::Program::IsPrime(int)': a.cc:65:43: error: 'Math' was not declared in this scope 65 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s820246658
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Program { static void Main(string[] args) { var primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } var number = int.Parse(input); var previousPrimeNumber = 0; var nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); } } public static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:49:15: error: expected ':' before 'static' 49 | public static bool IsPrime(int number) | ^~~~~~~ | : a.cc:75:6: error: expected ';' after class definition 75 | } | ^ | ; a.cc: In static member function 'static void _0044::Program::Main(int*)': a.cc:10:13: error: 'var' was not declared in this scope 10 | var primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:21: error: expected ';' before 'input' 21 | var input = Console.ReadLine(); | ^~~~~ a.cc:23:21: error: 'string' was not declared in this scope 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:23:42: error: 'input' was not declared in this scope; did you mean 'int'? 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:21: error: expected ';' before 'number' 25 | var number = int.Parse(input); | ^~~~~~ a.cc:26:21: error: expected ';' before 'previousPrimeNumber' 26 | var previousPrimeNumber = 0; | ^~~~~~~~~~~~~~~~~~~ a.cc:27:21: error: expected ';' before 'nextPrimeNumber' 27 | var nextPrimeNumber = 0; | ^~~~~~~~~~~~~~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc:45:44: error: 'previousPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~~~~~ a.cc:45:65: error: 'nextPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~ a.cc: In static member function 'static bool _0044::Program::IsPrime(int)': a.cc:65:43: error: 'Math' was not declared in this scope 65 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s576275698
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Program { static void Main(string[] args) { var primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } var number = int.Parse(input); var previousPrimeNumber = 0; var nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); } } public static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:49:15: error: expected ':' before 'static' 49 | public static bool IsPrime(int number) | ^~~~~~~ | : a.cc:75:6: error: expected ';' after class definition 75 | } | ^ | ; a.cc: In static member function 'static void _0044::Program::Main(int*)': a.cc:10:13: error: 'var' was not declared in this scope 10 | var primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:21: error: expected ';' before 'input' 21 | var input = Console.ReadLine(); | ^~~~~ a.cc:23:21: error: 'string' was not declared in this scope 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:23:42: error: 'input' was not declared in this scope; did you mean 'int'? 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:21: error: expected ';' before 'number' 25 | var number = int.Parse(input); | ^~~~~~ a.cc:26:21: error: expected ';' before 'previousPrimeNumber' 26 | var previousPrimeNumber = 0; | ^~~~~~~~~~~~~~~~~~~ a.cc:27:21: error: expected ';' before 'nextPrimeNumber' 27 | var nextPrimeNumber = 0; | ^~~~~~~~~~~~~~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc:45:44: error: 'previousPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~~~~~ a.cc:45:65: error: 'nextPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~ a.cc: In static member function 'static bool _0044::Program::IsPrime(int)': a.cc:65:43: error: 'Math' was not declared in this scope 65 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s945964003
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Programs { static void Main(string[] args) { var primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } var number = int.Parse(input); var previousPrimeNumber = 0; var nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); } } public static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:48:15: error: expected ':' before 'static' 48 | public static bool IsPrime(int number) | ^~~~~~~ | : a.cc:74:6: error: expected ';' after class definition 74 | } | ^ | ; a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)': a.cc:10:13: error: 'var' was not declared in this scope 10 | var primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:21: error: expected ';' before 'input' 21 | var input = Console.ReadLine(); | ^~~~~ a.cc:23:21: error: 'string' was not declared in this scope 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:23:42: error: 'input' was not declared in this scope; did you mean 'int'? 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:21: error: expected ';' before 'number' 25 | var number = int.Parse(input); | ^~~~~~ a.cc:26:21: error: expected ';' before 'previousPrimeNumber' 26 | var previousPrimeNumber = 0; | ^~~~~~~~~~~~~~~~~~~ a.cc:27:21: error: expected ';' before 'nextPrimeNumber' 27 | var nextPrimeNumber = 0; | ^~~~~~~~~~~~~~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc:45:44: error: 'previousPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~~~~~ a.cc:45:65: error: 'nextPrimeNumber' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~~~~~~~~~ a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)': a.cc:64:43: error: 'Math' was not declared in this scope 64 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s684176351
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Programs { static void Main(string[] args) { List<int> primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } int number = int.Parse(input); int previousPrimeNumber = 0; int nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); } } public static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:48:15: error: expected ':' before 'static' 48 | public static bool IsPrime(int number) | ^~~~~~~ | : a.cc:74:6: error: expected ';' after class definition 74 | } | ^ | ; a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)': a.cc:10:13: error: 'List' was not declared in this scope 10 | List<int> primeList = new List<int>(); | ^~~~ a.cc:10:18: error: expected primary-expression before 'int' 10 | List<int> primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:17: error: 'var' was not declared in this scope 21 | var input = Console.ReadLine(); | ^~~ a.cc:23:21: error: 'string' was not declared in this scope 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:23:42: error: 'input' was not declared in this scope; did you mean 'int'? 23 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:30: error: expected primary-expression before 'int' 25 | int number = int.Parse(input); | ^~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.Write("{0} {1}\n", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)': a.cc:64:43: error: 'Math' was not declared in this scope 64 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s407767202
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Programs { static void Main(string[] args) { List<int> primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } int number = int.Parse(input); int previousPrimeNumber = 0; int nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); } } static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:73:6: error: expected ';' after class definition 73 | } | ^ | ; a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)': a.cc:10:13: error: 'List' was not declared in this scope 10 | List<int> primeList = new List<int>(); | ^~~~ a.cc:10:18: error: expected primary-expression before 'int' 10 | List<int> primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:17: error: 'var' was not declared in this scope 21 | var input = Console.ReadLine(); | ^~~ a.cc:22:21: error: 'string' was not declared in this scope 22 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:22:42: error: 'input' was not declared in this scope; did you mean 'int'? 22 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:23:30: error: expected primary-expression before 'int' 23 | int number = int.Parse(input); | ^~~ a.cc:27:30: error: expected ')' before 'primeNumber' 27 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:27:25: note: to match this '(' 27 | foreach (var primeNumber in primeList) | ^ a.cc:27:17: error: 'foreach' was not declared in this scope 27 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:43:17: error: 'Console' was not declared in this scope 43 | Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)': a.cc:63:43: error: 'Math' was not declared in this scope 63 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s618014727
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Programs { static void Main(string[] args) { List<int> primeList = new List<int>(); for (int i = 1; i < 50022; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } int number = int.Parse(input); int previousPrimeNumber = 0; int nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); } } static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:26: error: 'string' has not been declared 8 | static void Main(string[] args) | ^~~~~~ a.cc:8:35: error: expected ',' or '...' before 'args' 8 | static void Main(string[] args) | ^~~~ a.cc:73:6: error: expected ';' after class definition 73 | } | ^ | ; a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)': a.cc:10:13: error: 'List' was not declared in this scope 10 | List<int> primeList = new List<int>(); | ^~~~ a.cc:10:18: error: expected primary-expression before 'int' 10 | List<int> primeList = new List<int>(); | ^~~ a.cc:15:21: error: 'primeList' was not declared in this scope 15 | primeList.Add(i); | ^~~~~~~~~ a.cc:21:17: error: 'var' was not declared in this scope 21 | var input = Console.ReadLine(); | ^~~ a.cc:22:21: error: 'string' was not declared in this scope 22 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:22:42: error: 'input' was not declared in this scope; did you mean 'int'? 22 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:23:30: error: expected primary-expression before 'int' 23 | int number = int.Parse(input); | ^~~ a.cc:27:30: error: expected ')' before 'primeNumber' 27 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:27:25: note: to match this '(' 27 | foreach (var primeNumber in primeList) | ^ a.cc:27:17: error: 'foreach' was not declared in this scope 27 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:43:17: error: 'Console' was not declared in this scope 43 | Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)': a.cc:63:43: error: 'Math' was not declared in this scope 63 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s273481226
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Programs { readonly static int MAX_NUMBER = 50022; static void Main(string[] args) { List<int> primeList = new List<int>(); for (int i = 1; i < MAX_NUMBER; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } int number = int.Parse(input); int previousPrimeNumber = 0; int nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); } } static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:9: error: 'readonly' does not name a type 8 | readonly static int MAX_NUMBER = 50022; | ^~~~~~~~ a.cc:10:26: error: 'string' has not been declared 10 | static void Main(string[] args) | ^~~~~~ a.cc:10:35: error: expected ',' or '...' before 'args' 10 | static void Main(string[] args) | ^~~~ a.cc:75:6: error: expected ';' after class definition 75 | } | ^ | ; a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)': a.cc:12:13: error: 'List' was not declared in this scope 12 | List<int> primeList = new List<int>(); | ^~~~ a.cc:12:18: error: expected primary-expression before 'int' 12 | List<int> primeList = new List<int>(); | ^~~ a.cc:13:33: error: 'MAX_NUMBER' was not declared in this scope 13 | for (int i = 1; i < MAX_NUMBER; i++) | ^~~~~~~~~~ a.cc:17:21: error: 'primeList' was not declared in this scope 17 | primeList.Add(i); | ^~~~~~~~~ a.cc:23:17: error: 'var' was not declared in this scope 23 | var input = Console.ReadLine(); | ^~~ a.cc:24:21: error: 'string' was not declared in this scope 24 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:24:42: error: 'input' was not declared in this scope; did you mean 'int'? 24 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:30: error: expected primary-expression before 'int' 25 | int number = int.Parse(input); | ^~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)': a.cc:65:43: error: 'Math' was not declared in this scope 65 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s408983832
p00044
C++
using System; using System.Collections.Generic; namespace _0044 { class Programs { readonly static int MAX_NUMBER = 50022; static void Main(string[] args) { List<int> primeList = new List<int>(); for (int i = 1; i < MAX_NUMBER; i++) { if (IsPrime(i)) { primeList.Add(i); } } while (true) { var input = Console.ReadLine(); if (string.IsNullOrEmpty(input)) { break; } int number = int.Parse(input); int previousPrimeNumber = 0; int nextPrimeNumber = 0; foreach (var primeNumber in primeList) { if (primeNumber < number) { previousPrimeNumber = primeNumber; } else if (primeNumber > number) { nextPrimeNumber = primeNumber; } if (nextPrimeNumber != 0) { break; } } Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); } } static bool IsPrime(int number) { if (number <= 1) { return false; } else if (number <= 3) { return true; } else if ((number % 2) == 0) { return false; } else { for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) { if (number % i == 0) { return false; } } } return true; } } } /* * * ・最小の素数 2 * ・最大の素数 50022 * */
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:8:9: error: 'readonly' does not name a type 8 | readonly static int MAX_NUMBER = 50022; | ^~~~~~~~ a.cc:10:26: error: 'string' has not been declared 10 | static void Main(string[] args) | ^~~~~~ a.cc:10:35: error: expected ',' or '...' before 'args' 10 | static void Main(string[] args) | ^~~~ a.cc:75:6: error: expected ';' after class definition 75 | } | ^ | ; a.cc: In static member function 'static void _0044::Program\U0000ff53::Main(int*)': a.cc:12:13: error: 'List' was not declared in this scope 12 | List<int> primeList = new List<int>(); | ^~~~ a.cc:12:18: error: expected primary-expression before 'int' 12 | List<int> primeList = new List<int>(); | ^~~ a.cc:13:33: error: 'MAX_NUMBER' was not declared in this scope 13 | for (int i = 1; i < MAX_NUMBER; i++) | ^~~~~~~~~~ a.cc:17:21: error: 'primeList' was not declared in this scope 17 | primeList.Add(i); | ^~~~~~~~~ a.cc:23:17: error: 'var' was not declared in this scope 23 | var input = Console.ReadLine(); | ^~~ a.cc:24:21: error: 'string' was not declared in this scope 24 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~~ a.cc:24:42: error: 'input' was not declared in this scope; did you mean 'int'? 24 | if (string.IsNullOrEmpty(input)) { break; } | ^~~~~ | int a.cc:25:30: error: expected primary-expression before 'int' 25 | int number = int.Parse(input); | ^~~ a.cc:29:30: error: expected ')' before 'primeNumber' 29 | foreach (var primeNumber in primeList) | ^~~~~~~~~~~ a.cc:29:25: note: to match this '(' 29 | foreach (var primeNumber in primeList) | ^ a.cc:29:17: error: 'foreach' was not declared in this scope 29 | foreach (var primeNumber in primeList) | ^~~~~~~ a.cc:45:17: error: 'Console' was not declared in this scope 45 | Console.WriteLine("{0} {1}", previousPrimeNumber, nextPrimeNumber); | ^~~~~~~ a.cc: In static member function 'static bool _0044::Program\U0000ff53::IsPrime(int)': a.cc:65:43: error: 'Math' was not declared in this scope 65 | for (int i = 3; i <= (int)Math.Sqrt(number); i += 2) | ^~~~
s456253570
p00044
C++
#include <iostream> #include <vector> using namespace std; typedef vector <int> vi; #define REP1(i,n1,n2) for (int i=n1; i<n2; i++) vi primes; int get_primes(int m){ int n = (m+1)/2, root = (int)(pow(n, 0.5)); vector <bool> N(n, true); N[0]=false; if (m>1) primes.push_back(2); REP1(i,1,root){ int tmp = i*2+1; if (N[i]){ primes.push_back(tmp); for (int j=i+tmp; j<n+1; j+=tmp) N[j]=false; } } REP1(i,root,n+1) if(N[i]) primes.push_back(2*i+1); return 0; } int main(){ get_primes(50100); while (true){ int n,a,b; cin>>n; if (cin.eof()) break; REP1(i,0,(int)primes.size()){ a=primes[i]; if (a<n) b=a; else if (a>n) break; } cout<<b<<" "<<a<<endl; } }
a.cc: In function 'int get_primes(int)': a.cc:9:35: error: 'pow' was not declared in this scope 9 | int n = (m+1)/2, root = (int)(pow(n, 0.5)); | ^~~
s078905185
p00045
Java
import java.io.*; class Main{ public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; int sum=0; int amount=0; int p=0; int q=0; int count=0; while((line=br.readLine())!=null){ String[] values=line.split(","); p=Integer.parseInt(values[0]); q=Integer.parseInt(values[1]); sum+=p*q; amount+=q; count++; } System.out.println(sum); System.out.println(Math.round((flaot)amount/count)); } }
Main.java:21: error: cannot find symbol System.out.println(Math.round((flaot)amount/count)); ^ symbol: class flaot location: class Main 1 error
s625593667
p00045
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class AOJ_0045 { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer[]> inputList = new ArrayList<>(); while (input.ready()) { final String[] inputStrArray = input.readLine().split(","); final Integer[] inputIntArray = { Integer.parseInt(inputStrArray[0]), Integer.parseInt(inputStrArray[1]) }; inputList.add(inputIntArray); } final int[] ans = solver(inputList); System.out.println(ans[0]); System.out.println(ans[1]); } private static int[] solver(ArrayList<Integer[]> list) { int prodSum = 0; double sum = 0; for (Integer[] each : list) { prodSum += each[0] * each[1]; sum += each[1]; } final int[] ret = { prodSum, (int) Math.round(sum / list.size()) }; return ret; } }
Main.java:6: error: class AOJ_0045 is public, should be declared in a file named AOJ_0045.java public class AOJ_0045 ^ 1 error
s484606853
p00045
Java
public class Main { public static void main(String[] args) { int price; int n; int all = 0; int allN = 0; int rCount = 0; for (Scanner in = new Scanner(System.in); in.hasNext();) { String[] r = in.next().split(","); price = Integer.parseInt(r[0]); n = Integer.parseInt(r[1]); all += price * n; allN += n; rCount++; } System.out.println(all); System.out.println(Math.round((float) allN / rCount)); } }
Main.java:8: error: cannot find symbol for (Scanner in = new Scanner(System.in); in.hasNext();) { ^ symbol: class Scanner location: class Main Main.java:8: error: cannot find symbol for (Scanner in = new Scanner(System.in); in.hasNext();) { ^ symbol: class Scanner location: class Main 2 errors
s236958413
p00045
Java
import java.io.*; class Main { public static void main(String args[])throws IOException { BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String str; int sum=0; float n=0,ave,j=1f; while((str=input.readLine())!=null) { String str_ary[]=str.split(","); int a[]=new int[2]; for(int i=0;i<2;i++) { a[i]=Integer.parseInt(str_ary[i]); } sum+=a[0]*a[1]; n+=a[1]; ave=n/j; if(ave%1>0.4)ave++; j++; } System.out.println(sum+"\n"+(int)(ave)); } }
Main.java:27: error: variable ave might not have been initialized System.out.println(sum+"\n"+(int)(ave)); ^ 1 error
s434076955
p00045
C
#include <stdio.h> int main(void) { int a, b, sum_a = 0, sum_b = 0, c = 0; int syousuu = 0; while (scanf("%d,%d", &a, &b) != EOF){ sum_a += a * b; sum_b += b; c++; } if (sum_b % c != 0 && 2 * (sum_b % c) >= c){ syousuu = 1; } printf("%d\n%d\n", sum_a, syousuu + sum_b / c;); return (0); }
main.c: In function 'main': main.c:17:54: error: expected ')' before ';' token 17 | printf("%d\n%d\n", sum_a, syousuu + sum_b / c;); | ~ ^ | )
s143314943
p00045
C
#include<stdio.h> int main(void){ int a, b, c, sum, i, n, ave2; double ave; while(scanf("%d, %d", &a, &b) = EOF){ sum = sum + a * b; n = n + b; } ave = su / n; ave = ave * 2; ave2 = ave / 2; printf("%d\n%d\n", sum, ave2); return 0; }
main.c: In function 'main': main.c:5:34: error: lvalue required as left operand of assignment 5 | while(scanf("%d, %d", &a, &b) = EOF){ | ^ main.c:9:10: error: 'su' undeclared (first use in this function); did you mean 'sum'? 9 | ave = su / n; | ^~ | sum main.c:9:10: note: each undeclared identifier is reported only once for each function it appears in
s789951058
p00045
C
#include<stdio.h> int main(void){ int a, b, sum, n, ave2; double ave; sum = 0; n = 0; while ( scanf("%d, %d", &a, &b) != EOF ){ sum = sum + a * b; n = n + b; k++; } ave = n / k; ave = ave + 0.5; ave2 = ave; printf("%d\n%d\n", sum, ave2); return 0; }
main.c: In function 'main': main.c:10:7: error: 'k' undeclared (first use in this function) 10 | k++; | ^ main.c:10:7: note: each undeclared identifier is reported only once for each function it appears in
s996785979
p00045
C
#include<stdio.h> int main(void){ ??????int a, b, sum, n, ave, k; ??????sum = 0; ??????n = 0; ??????k = 0; ??????while ( scanf("%d,%d", &a, &b) != EOF ){ ????????????sum = sum + a * b; ????????????n = n + b; ????????????k++; ??????} ??????ave = n / k * 10 + 5 / 2; ??????printf("%d\n%d\n", sum, ave); ??????return 0; }
main.c: In function 'main': main.c:5:1: error: expected expression before '?' token 5 | ??????int a, b, sum, n, ave, k; | ^ main.c:7:1: error: expected expression before '?' token 7 | ??????sum = 0; | ^ main.c:7:7: error: 'sum' undeclared (first use in this function) 7 | ??????sum = 0; | ^~~ main.c:7:7: note: each undeclared identifier is reported only once for each function it appears in main.c:9:1: error: expected expression before '?' token 9 | ??????n = 0; | ^ main.c:9:7: error: 'n' undeclared (first use in this function) 9 | ??????n = 0; | ^ main.c:11:1: error: expected expression before '?' token 11 | ??????k = 0; | ^ main.c:11:7: error: 'k' undeclared (first use in this function) 11 | ??????k = 0; | ^ main.c:13:1: error: expected expression before '?' token 13 | ??????while ( scanf("%d,%d", &a, &b) != EOF ){ | ^ main.c:25:1: error: expected expression before '?' token 25 | ??????printf("%d\n%d\n", sum, ave); | ^ main.c:25:31: error: 'ave' undeclared (first use in this function) 25 | ??????printf("%d\n%d\n", sum, ave); | ^~~ main.c:27:1: error: expected expression before '?' token 27 | ??????return 0; | ^
s768121653
p00045
C
#include<stdio.h> int main(void){ int a, b, sum, n, ave, k; sum = 0; n = 0; k = 0; while ( scanf("%d,%d", &a, &b) != EOF ){ sum = sum + a * b; n = n + b; k++; } ave = ( n / k * 10 + 5 ) / 10; printf("%d\n%d\n", sum, ave2); return 0; }
main.c: In function 'main': main.c:13:28: error: 'ave2' undeclared (first use in this function); did you mean 'ave'? 13 | printf("%d\n%d\n", sum, ave2); | ^~~~ | ave main.c:13:28: note: each undeclared identifier is reported only once for each function it appears in
s154838812
p00045
C
#include<stdio.h> int main(){ int a, b, sum, n, ave, k; sum = 0; n = 0; k = 0; while ( scanf("%d,%d", &a, &b) != EOF ){ sum = sum + a * b; n = n + b; k++; } ave = ( n / k * 10 + 5 ) / 10; printf("%d\n%d\n", sum, ave2); return 0; }
main.c: In function 'main': main.c:13:28: error: 'ave2' undeclared (first use in this function); did you mean 'ave'? 13 | printf("%d\n%d\n", sum, ave2); | ^~~~ | ave main.c:13:28: note: each undeclared identifier is reported only once for each function it appears in