submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s989138360
p00253
C++
#include <cstdio> #include <iostream> #include <stdlib.h> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <windows.h> using namespace std; int main(){ int n; while(cin >> n){ if(n == 0){break;} int nae[n + 1],m = 0,ans = 0,c = 0,mm; for(int i = 0;n >= i;i++){ cin >> nae[i]; if(i != 0){ if(nae[i] <= nae[i - 1]){ans = nae[i - 1];m = 0;} if(m == 0){m = nae[i] - nae[i - 1];} mm = nae[i] - nae[i - 1]; //cout << m << " " << mm << endl; if(m != nae[i] - nae[i - 1]){ ans = nae[i];c++; for(int ii = i;n > ii;ii++){ nae[i] = nae[i + 1]; } n--;i--; } //cout << "AA" << ans << endl; } } if(c > 1){ans = nae[0];} cout << ans << endl; } }
a.cc:8:10: fatal error: windows.h: No such file or directory 8 | #include <windows.h> | ^~~~~~~~~~~ compilation terminated.
s183484290
p00253
C++
#include <cstdio> #include <iostream> #include <stdlib.h> #include <iomanip> #include <string> #include <sstream> #include <vector> #include <windows.h> using namespace std; int main(){ int n; while(cin >> n){ if(n == 0){break;} int nae[n + 1],m = 0,ans = 0,c = 0,mm; for(int i = 0;n >= i;i++){ cin >> nae[i]; if(i != 0){ if(nae[i] <= nae[i - 1]){ans = nae[i - 1];m = 0;} if(m == 0){m = nae[i] - nae[i - 1];} mm = nae[i] - nae[i - 1]; //cout << m << " " << mm << endl; if(m != nae[i] - nae[i - 1]){ ans = nae[i];c++; for(int ii = i;n > ii;ii++){ nae[i] = nae[i + 1]; } n--;i--; } //cout << "AA" << ans << endl; } } if(c > 1){ans = nae[0];} cout << ans << endl; } }
a.cc:8:10: fatal error: windows.h: No such file or directory 8 | #include <windows.h> | ^~~~~~~~~~~ compilation terminated.
s354698622
p00253
C++
int main(){ int n; cin >> n; int nae[n + 1]; for(int i = 0;n >= i;i++){ cin >> nae[i]; } int ans = 0; for(int i = 0;n >= i;i++){ int c = 0;m = 0; for(int ii = i + 1;n > ii;ii++){ if(m = 0){m = nae[ii + 1] - nae[ii];} if(m != nae[ii + 1] - nae[ii]){c = 1;break;} } if(c != 0){ ans = nae[i];break; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:3:9: error: 'cin' was not declared in this scope 3 | cin >> n; | ^~~ a.cc:10:27: error: 'm' was not declared in this scope 10 | int c = 0;m = 0; | ^ a.cc:20:9: error: 'cout' was not declared in this scope 20 | cout << ans << endl; | ^~~~ a.cc:20:24: error: 'endl' was not declared in this scope 20 | cout << ans << endl; | ^~~~
s143362741
p00253
C++
#include <cstdio> #include <iostream> #include <iomanip> #include <string> using namespace std; int main(){ while(cin >> n){ int n,m,ans; cin >> n; int nae[n + 1]; for(int i = 0;n >= i;i++){ cin >> nae[i]; } int ans = 0; for(int i = 0;n >= i;i++){ int c = 0;m = 0; for(int ii = i + 1;n > ii;ii++){ if(m = 0){m = nae[ii + 1] - nae[ii];} if(m != nae[ii + 1] - nae[ii]){c = 1;break;} } if(c != 0){ ans = nae[i];break; } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:8:22: error: 'n' was not declared in this scope 8 | while(cin >> n){ | ^ a.cc:13:32: error: 'nae' was not declared in this scope 13 | cin >> nae[i]; | ^~~ a.cc:15:21: error: redeclaration of 'int ans' 15 | int ans = 0; | ^~~ a.cc:9:25: note: 'int ans' previously declared here 9 | int n,m,ans; | ^~~ a.cc:19:47: error: 'nae' was not declared in this scope 19 | if(m = 0){m = nae[ii + 1] - nae[ii];} | ^~~ a.cc:20:41: error: 'nae' was not declared in this scope 20 | if(m != nae[ii + 1] - nae[ii]){c = 1;break;} | ^~~ a.cc:23:39: error: 'nae' was not declared in this scope 23 | ans = nae[i];break; | ^~~
s460426240
p00253
C++
#include <cstdio> #include <iostream> #include <iomanip> #include <string> using namespace std; int main(){ while(cin >> n){ int n; cin >> n; int nae[n + 1]; for(int i = 0;n >= i;i++){ cin >> nae[i]; } int ans = 0; for(int i = 0;n >= i;i++){ int c = 0;m = 0; for(int ii = i + 1;n > ii;ii++){ if(m = 0){m = nae[ii + 1] - nae[ii];} if(m != nae[ii + 1] - nae[ii]){c = 1;break;} } if(c != 0){ ans = nae[i];break; } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:8:22: error: 'n' was not declared in this scope 8 | while(cin >> n){ | ^ a.cc:13:32: error: 'nae' was not declared in this scope 13 | cin >> nae[i]; | ^~~ a.cc:17:35: error: 'm' was not declared in this scope 17 | int c = 0;m = 0; | ^ a.cc:19:47: error: 'nae' was not declared in this scope 19 | if(m = 0){m = nae[ii + 1] - nae[ii];} | ^~~ a.cc:20:41: error: 'nae' was not declared in this scope 20 | if(m != nae[ii + 1] - nae[ii]){c = 1;break;} | ^~~ a.cc:23:39: error: 'nae' was not declared in this scope 23 | ans = nae[i];break; | ^~~
s369536043
p00253
C++
#include <cstdio> #include <iostream> #include <iomanip> #include <string> using namespace std; int main(){ int n; while(cin >> n){ cin >> n; int nae[n + 1]; for(int i = 0;n >= i;i++){ cin >> nae[i]; } int ans = 0; for(int i = 0;n >= i;i++){ int c = 0;m = 0; for(int ii = i + 1;n > ii;ii++){ if(m = 0){m = nae[ii + 1] - nae[ii];} if(m != nae[ii + 1] - nae[ii]){c = 1;break;} } if(c != 0){ ans = nae[i];break; } } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:17:35: error: 'm' was not declared in this scope 17 | int c = 0;m = 0; | ^
s286429844
p00253
C++
#include <stdio.h> int main(void) { int n,i,j,k; int h[102]; int tmp[102]; int sa[102] while(1){ scanf("%d",&n); if(n==0) break; for(i=0;i<=100;i++) sa[i]; for(i=0;i<=n;i++) scanf("%d",&h[i]); for(i=0;i<=n;i++){ for(j=0;j<=100;j++) tmp[j]=0; for(j=0;j<=n;j++){ if(i!=j){ tmp[j]=h[j]; } } /* for(j=0;j<=n;j++) printf("%d ",tmp[j]); printf("\n");*/ int k=0; for(i=0;i<=100;i++) sa[i]=0; for(j=0;j<=n;j++){ if(tmp[j]!=0){ sa[k]=tmp[j]; k++; } } /* for(j=0;j<n;j++) printf("%d ",sa[j]); printf("\n"); */ int ans=0,flg=0; for(j=0;j<n-1;j++){ if(j==0){ ans=sa[j]-sa[j+1]; } else if(ans!=sa[j]-sa[j+1]){ flg=1; break; } } if(flg==0){ printf("%d\n",h[i]); } // printf(" %d\n",flg); } // printf("\n"); } return 0; }
a.cc: In function 'int main()': a.cc:7:5: error: expected initializer before 'while' 7 | while(1){ | ^~~~~
s798290805
p00253
C++
#include<stdio.h> int main() { int a[101], n, b, b1 = 1, c, c1 = 0, d, i, j = -1, pp; scanf_s("%d", &n); while (n != 0) { for (i = 0; i < n + 1; i++) { scanf_s("%d", &a[i]); } b = a[1] - a[0]; for (i = 2; i < n + 1; i++) { if (b == a[i] - a[i - 1]) { b1++; } else { c = a[i] - a[i - 1]; c1++; } } if (c1 > b1) { b = c; } for (i = 1; i < n; i++) { if (b != a[i] - a[i - 1] && b != a[i + 1] - a[i]) { j = i; break; } } if (j == -1) { if (b != a[1] - a[0]) { j = 0; } else { j = n; } } printf("%d\n", a[j]); scanf_s("%d", &n); c1 = 0; b1 = 0; j = -1; } return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 5 | scanf_s("%d", &n); | ^~~~~~~ | scanf
s891923891
p00253
C++
#include <stdio.h> int main(void){ int n,i,a[101],y,o,s,n,w; //s:??????,y:??¬???,n:??? scanf("%d",&n); scanf("%d",&a[1]); s=a[1]; for(i=2;i<=n+1;i++){ scanf("%d",&a[i]); } if(a[2]-a[1]==a[3]-a[2]){ y=a[2]-a[1]; } else if(a[3]-a[2]==a[4]-a[3]){ y=a[3]-a[2]; } else{ y=a[5]-a[4]; } for(i=1;i<=n+1;i++){ o=s+((i-1)*y); if(o!=a[i]){ n=a[i]; w=s+((3-1)*y); if(i==2&&w!=a[3]){ n=a[1]; } break; } } printf("%d\n",n); return 0; }
a.cc: In function 'int main()': a.cc:3:30: error: redeclaration of 'int n' 3 | int n,i,a[101],y,o,s,n,w; //s:??????,y:??¬???,n:??? | ^ a.cc:3:13: note: 'int n' previously declared here 3 | int n,i,a[101],y,o,s,n,w; //s:??????,y:??¬???,n:??? | ^
s336275177
p00253
C++
#include <stdio.h> int main(void){ int n,i,a[101],y,o,s,n,w; //s:??????,y:??¬???,n:??? scanf("%d",&n); while(n!=0){ scanf("%d",&a[1]); s=a[1]; for(i=2;i<=n+1;i++){ scanf("%d",&a[i]); } if(a[2]-a[1]==a[3]-a[2]){ y=a[2]-a[1]; } else if(a[3]-a[2]==a[4]-a[3]){ y=a[3]-a[2]; } else{ y=a[5]-a[4]; } for(i=1;i<=n+1;i++){ o=s+((i-1)*y); if(o!=a[i]){ n=a[i]; w=s+((3-1)*y); if(i==2&&w!=a[3]){ n=a[1]; } break; } } printf("%d\n",n); scanf("%d",&n); } return 0; }
a.cc: In function 'int main()': a.cc:3:30: error: redeclaration of 'int n' 3 | int n,i,a[101],y,o,s,n,w; //s:??????,y:??¬???,n:??? | ^ a.cc:3:13: note: 'int n' previously declared here 3 | int n,i,a[101],y,o,s,n,w; //s:??????,y:??¬???,n:??? | ^
s491919541
p00253
C++
#include<iostream> #include<vector> using namespace std; static const int N = 100; bool isSequence(vector<int> v){ int d = v[1] - v[0]; for ( int i = 1; i < v.size(); i++ ){ if ( v[i] - v[i-1] != d ) return false; } return true; }
/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
s499435698
p00253
C++
#include"bits/stdc++.h" #define rep(i,n) for(int i=0;i<n;i++) typedef long long ll; using namespace std; ?? int a[101]; int main(){ int n; scanf("%d", &n); for (int i = 0; i <= n; i++){ scanf("%d", &a[i]); } bool flag = true; int s = -1; int i; for (i = 0; i <= n; i++){ for (int j = 0; j < n; j++){ if (j == i)continue; int t = 1; while (j + t == i&&j + t < n) t++; if (j + t == i)continue; if (s == -1 || a[j + t] - a[j] == s){ s = a[j + t] - a[j]; } else flag = false; } if (flag)break; flag = true; s = -1; } printf("%d\n", a[i]); return 0; }
a.cc:5:1: error: expected unqualified-id before '?' token 5 | ?? | ^ a.cc: In function 'int main()': a.cc:11:30: error: 'a' was not declared in this scope 11 | scanf("%d", &a[i]); | ^ a.cc:23:40: error: 'a' was not declared in this scope 23 | if (s == -1 || a[j + t] - a[j] == s){ | ^ a.cc:32:24: error: 'a' was not declared in this scope 32 | printf("%d\n", a[i]); | ^
s165063299
p00253
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <cstdio> #include <string> #include <cctype> using namespace std; int main() { int n,h,R=0; int d; cin>>n; while(1){ if (n==0)break; for(int i=0;i<n+1;i++){ cin>>h; } for(int i=0;i<n+1;i++){ d=h[1]-h[0]; if (h[i+1]-h[i]!=d)d=h[i+1]-h[1]; } cout<<R<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:28: error: invalid types 'int[int]' for array subscript 25 | d=h[1]-h[0]; | ^ a.cc:25:33: error: invalid types 'int[int]' for array subscript 25 | d=h[1]-h[0]; | ^ a.cc:26:30: error: invalid types 'int[int]' for array subscript 26 | if (h[i+1]-h[i]!=d)d=h[i+1]-h[1]; | ^ a.cc:26:37: error: invalid types 'int[int]' for array subscript 26 | if (h[i+1]-h[i]!=d)d=h[i+1]-h[1]; | ^ a.cc:26:47: error: invalid types 'int[int]' for array subscript 26 | if (h[i+1]-h[i]!=d)d=h[i+1]-h[1]; | ^ a.cc:26:54: error: invalid types 'int[int]' for array subscript 26 | if (h[i+1]-h[i]!=d)d=h[i+1]-h[1]; | ^
s316799696
p00253
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <cstdlib> #include <cstring> #include <cmath> #include <vector> #include <queue> using namespace std; #define FOR(i,a,b) for (ll i = (a); i < (b); i++) #define REP(i,n) FOR(i,0,n) typedef long long ll; ll h[101]; int main(){ int n; while (cin >> n, n){ ll d1, d2, d3, d4, d5, d6, d7, d; REP(i,n+1){ scanf("%lld", &h[i]); } d1 = h[1] - h[0]; d2 = h[2] - h[1]; d3 = h[2] - h[0]; d4 = h[3] - h[2]; d5 = h[3] - h[1]; d6 = h[4] - h[3]; d7 = h[4] - h[2]; ll ans = 0; int f = 0; if (d1 == d2 && d1 == d4){ f = 1; d = d1; } else if (d2 == d4 && d2 == d6){ ans = h[0]; } else if (d3 == d4 && d3 == d7){ ans = h[1]; } else if (d1 == d5 && ){ ans = h[2]; } else if (d1 == d2){ f = 1; d = d1; } if (f){ int c = h[0]; REP(i,n+1){ if (c != h[i]){ ans = h[i]; break; } c += d; } } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:50:38: error: expected primary-expression before ')' token 50 | else if (d1 == d5 && ){ | ^
s995810418
p00253
C++
#include<stdio.h> int main(void) { int x,y,z,a[500],i,n,j; scanf("%d",&j); while(j!=0){ z=0; y=0; x=0; for(i=0;i<j+1;i++){ scanf("%d",&a[i]); } for(i=0;i<j;i++){ n=i+1; z=a[n]-a[i]; if(x!=0){ if(x!=y && y==z){ i=i-2; break; } if(y==x && y!=z){ i=n; break; } } x=y; y=z; } printf("%d\n",a[i]); scanf("%d",&j); } return 0;
a.cc: In function 'int main()': a.cc:33:18: error: expected '}' at end of input 33 | return 0; | ^ a.cc:3:1: note: to match this '{' 3 | { | ^
s627710742
p00253
C++
include <iostream> using namespace std; int main(){ long int n,leaf[100],mem,mem2,a,same; while(1){ cin >> n; if(n == 0) break; a=0; for(int i=0;i<n+1;i++) cin >> leaf[i]; for(int i=0;i<n-1;i++){ mem = leaf[i+1] - leaf[i]; mem2 = leaf[i+2] - leaf[i+1]; if(mem2 != mem) a = i; else same = mem; if(i == n-2 && (leaf[i+2] - leaf[i+1] != same)){ if(leaf[i+2] - same != leaf[i+1]) a = i+2; if(leaf[i+1] - same != leaf[i]) a = i+1; } } cout << leaf[a] << endl; } }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:7:9: error: 'cin' was not declared in this scope 7 | cin >> n; | ^~~ a.cc:21:9: error: 'cout' was not declared in this scope 21 | cout << leaf[a] << endl; | ^~~~ a.cc:21:28: error: 'endl' was not declared in this scope 21 | cout << leaf[a] << endl; | ^~~~
s674936414
p00253
C++
int main(void) { //入力変数 int n = 0; //入力配列 int h_input[101] = {0}; //一時入力変数 int h_hozon[101] = {0}; while (true) { cin >> n; if (n == 0) { return 0; } //入力する for (int i = 0; i <= n; i++) { cin >> h_input[i]; } for (int i = 0; i <= n; i++) { int count = 0; for (int j = 0; j <= n; j++) { if (i != j) { h_hozon[count++] = h_input[j]; } } //forを回して調べる int sa = h_hozon[1] - h_hozon[0]; int k = 0; for (k = 0; k < n - 1; k++) { if (h_hozon[k] + sa != h_hozon[k + 1]) { break; } } if (k == n - 1) { cout << h_input[i] << endl; break; } } } return 0; }
a.cc: In function 'int main()': a.cc:12:17: error: 'cin' was not declared in this scope 12 | cin >> n; | ^~~ a.cc:46:33: error: 'cout' was not declared in this scope; did you mean 'count'? 46 | cout << h_input[i] << endl; | ^~~~ | count a.cc:46:55: error: 'endl' was not declared in this scope 46 | cout << h_input[i] << endl; | ^~~~
s844704848
p00254
Java
import java.util.Collections; import java.util.Scanner; import java.util.Arrays; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int L=0,S=0,j=0,cnt=0,ksan,ksan2; Integer[] le = new Integer[4]; Integer[] se = new Integer[4]; ksan = sc.nextInt(); if(ksan==1111||ksan==2222||ksan==3333||ksan==4444||ksan==5555||ksan==6666||ksan==7777||ksan==8888||ksan==9999){ System.out.println("NA"); ksan = sc.nextInt(); }else if(ksan == 6174){ System.out.println(0); ksan = sc.nextInt(); } while(ksan != 0000){ if(ksan == 6174){ System.out.println(cnt); ksan = sc.nextInt(); }else if(ksan==1111||ksan==2222||ksan==3333||ksan==4444||ksan==5555||ksan==6666||ksan==7777||ksan==8888||ksan==9999){ System.out.println("NA"); ksan = sc.nextInt(); }else{ ksan2 = ksan; for(int a=1000;a>=1;a = a/10){ ksan2 = ksan/a; le[j] = ksan2; se[j] = ksan2; ksan = ksan - le[j]*a; j++; } Arrays.sort(le,Collections.reverseOrder()); Arrays.sort(se); int bai = 1000; for(int b=1;b<=4;b++){ L = L + le[b-1] * bai; S = S + se[b-1] * bai; bai = bai/10; } ksan = L-S; L = 0; S = 0; j=0; cnt++; } } } }
Main.java:4: error: class main is public, should be declared in a file named main.java public class main { ^ 1 error
s447298193
p00254
Java
import java.util.Collections; import java.util.Scanner; import java.util.Arrays; public class MAIN { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int L=0,S=0,j=0,cnt=0,ksan,ksan2; Integer[] le = new Integer[4]; Integer[] se = new Integer[4]; ksan = sc.nextInt(); if(ksan==1111||ksan==2222||ksan==3333||ksan==4444||ksan==5555||ksan==6666||ksan==7777||ksan==8888||ksan==9999){ System.out.println("NA"); ksan = sc.nextInt(); }else if(ksan == 6174){ System.out.println(0); ksan = sc.nextInt(); } while(ksan != 0000){ if(ksan == 6174){ System.out.println(cnt); ksan = sc.nextInt(); }else if(ksan==1111||ksan==2222||ksan==3333||ksan==4444||ksan==5555||ksan==6666||ksan==7777||ksan==8888||ksan==9999){ System.out.println("NA"); ksan = sc.nextInt(); }else{ ksan2 = ksan; for(int a=1000;a>=1;a = a/10){ ksan2 = ksan/a; le[j] = ksan2; se[j] = ksan2; ksan = ksan - le[j]*a; j++; } Arrays.sort(le,Collections.reverseOrder()); Arrays.sort(se); int bai = 1000; for(int b=1;b<=4;b++){ L = L + le[b-1] * bai; S = S + se[b-1] * bai; bai = bai/10; } ksan = L-S; L = 0; S = 0; j=0; cnt++; } } } }
Main.java:4: error: class MAIN is public, should be declared in a file named MAIN.java public class MAIN { ^ 1 error
s615814228
p00254
C
#include <stdio.h> #include <string.h> #define swap(a, b, type) {type tmp = a; a = b; b = tmp;} int main(void) { char str[8]; while (scanf("%s", str) * str[0] != 0){ int count = 0; while (strcmp(str, "6174") != 0){ int i, j; char l[8], s[8]; strcpy(l, str); strcpy(s, str); for (i = 0; i < 3; i++){ for (j = 0; j < 3 - i; j++){ if (l[j] < l[j + 1]){ swap(l[j], l[j + 1]); } if (s[j] > s[j + 1]){ swap(s[j], s[j + 1]); } } } for (i = 0; i < 4; i++){ str[i] = l[i] - s[i] + '0'; } } printf("%d\n", count); } return 0; }
main.c: In function 'main': main.c:22:68: error: macro "swap" requires 3 arguments, but only 2 given 22 | swap(l[j], l[j + 1]); | ^ main.c:4:9: note: macro "swap" defined here 4 | #define swap(a, b, type) {type tmp = a; a = b; b = tmp;} | ^~~~ main.c:22:49: error: 'swap' undeclared (first use in this function) 22 | swap(l[j], l[j + 1]); | ^~~~ main.c:22:49: note: each undeclared identifier is reported only once for each function it appears in main.c:25:68: error: macro "swap" requires 3 arguments, but only 2 given 25 | swap(s[j], s[j + 1]); | ^ main.c:4:9: note: macro "swap" defined here 4 | #define swap(a, b, type) {type tmp = a; a = b; b = tmp;} | ^~~~
s544254231
p00254
C
#include <cstdio> #include <algorithm> using namespace std; int main() { int N[4], L[4], S[4], l, s, i, num; char input[5]; while (1){ scanf("%s", input); for (i = 0; i < 4; i++){ N[i] = input[i] - '0'; } if (input[0] == '0' && input[1] == '0' && input[2] == '0' && input[3] == '0'){ break; } if (input[0] == input[1] && input[0] == input[2] && input[0] == input[3]){ printf("NA\n"); continue; } num = 0; while (1){ if (N[0] == 6 && N[1] == 1 && N[2] == 7 && N[3] == 4){ break; } for (i = 0; i < 4; i++){ L[i] = N[i]; S[i] = N[i]; } sort(L, L + 4); reverse(L, L + 4); sort(S, S + 4); for (i = 3; i >= 0; i--){ N[i] = L[i] - S[i]; if (N[i] < 0){ N[i] += 10; L[i - 1]--; } } num++; } printf("%d\n", num); } return (0); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s414411834
p00254
C
#include <stdio.h> #include <stdlib.h> void sort(char *n, int type); void swap(char *a, char *b); int main(void) { char num[5]; int L, S; int count; while (1){ scanf("%s", num); if (num[0] == num[1] && num[1] == num[2] && num[2] == num[3]) { puts("NA"); break; } count = 0; while (!(num[0] == '6' && num[1] == '1' && num[2] == '7' && num[3] == '4')){ sort(num, 1); L = atoi(num); sort(num, 0); S = atoi(num); itoa(L - S, num, 10); count++; } printf("%d\n", count); } return (0); } void sort(char *n, int type) { int i, j; for (i = 0; i < 3; i++){ for (j = 3; j > i; j--){ if (type == 0 && (n[j - 1] - '0') > (n[j] - '0')){ swap(&n[j - 1], &n[j]); } if (type == 1 && (n[j - 1] - '0') < (n[j] - '0')){ swap(&n[j - 1], &n[j]); } } } } void swap(char *a, char *b) { char tmp = *a; *a = *b; *b = tmp; }
main.c: In function 'main': main.c:29:25: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration] 29 | itoa(L - S, num, 10); | ^~~~
s195205128
p00254
C
#include<stdio.h> int main(void) { int n,a[4],i,j,t,l,s,o=0; while(1) { o=0; scanf("%d",&n); if(n==0) { break; } while(1) { if(n==1111||n==2222||n==3333||n==4444||n==5555||n==6666||n==7777||n==8888||n=9999) { printf("NA\n"); break; } if(n==6174) { printf("%d\n",o); break; } a[0]=n/1000; a[1]=n%1000/100; a[2]=n%1000%100/10; a[3]=n%1000%100%10; for(i=0;i<4;i++) { for(j=i+1;j<4;j++) { if(a[i]<a[j]) { t=a[i]; a[i]=a[j]; a[j]=t; } } } l=a[0]*1000+a[1]*100+a[2]*10+a[3]; s=a[3]*1000+a[2]*100+a[1]*10+a[0]; n=l-s; o++; } } return 0; }
main.c: In function 'main': main.c:16:101: error: lvalue required as left operand of assignment 16 | if(n==1111||n==2222||n==3333||n==4444||n==5555||n==6666||n==7777||n==8888||n=9999) | ^
s470693594
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; for (;;) { k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10; g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { for (rina=0;rina<=4;rina++) { m[rina]=h; } } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; for (h=0;h<=10;h++) { if=(g[h]==1) { for (rina=0;rina<=4;rina++) { m[rina]=h; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m=[10]={0},n,rina,suzuki; | ^ main.c:7:17: error: 'k' undeclared (first use in this function) 7 | k=0; | ^ main.c:12:30: error: expected ';' before numeric constant 12 | break 0; | ^~ | ; main.c:29:27: error: expected expression before '[' token 29 | g=[e]=1; | ^ main.c:32:30: error: 'h' undeclared (first use in this function) 32 | for (h=10;h<=0;h--) | ^ main.c:36:46: error: 'rina' undeclared (first use in this function) 36 | for (rina=0;rina<=4;rina++) | ^~~~ main.c:38:49: error: 'm' undeclared (first use in this function) 38 | m[rina]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:46:35: error: expected '(' before '=' token 46 | if=(g[h]==1) | ^ | ( main.c:46:45: error: expected ';' before '{' token 46 | if=(g[h]==1) | ^ | ; 47 | { | ~ main.c:54:29: error: 'j' undeclared (first use in this function) 54 | b=i-j; | ^ main.c:55:25: error: 'l' undeclared (first use in this function) 55 | l++; | ^ main.c:60:1: error: expected declaration or statement at end of input 60 | } | ^
s519695684
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; for (;;) { k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10; g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { for (rina=0;rina<=4;rina++) { m[rina]=h; } } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; for (h=0;h<=10;h++) { if=(g[h]==1) { for (rina=0;rina<=4;rina++) { m[rina]=h; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:7:17: error: 'k' undeclared (first use in this function) 7 | k=0; | ^ main.c:12:30: error: expected ';' before numeric constant 12 | break 0; | ^~ | ; main.c:29:27: error: expected expression before '[' token 29 | g=[e]=1; | ^ main.c:32:30: error: 'h' undeclared (first use in this function) 32 | for (h=10;h<=0;h--) | ^ main.c:36:46: error: 'rina' undeclared (first use in this function) 36 | for (rina=0;rina<=4;rina++) | ^~~~ main.c:38:49: error: 'm' undeclared (first use in this function) 38 | m[rina]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:46:35: error: expected '(' before '=' token 46 | if=(g[h]==1) | ^ | ( main.c:46:45: error: expected ';' before '{' token 46 | if=(g[h]==1) | ^ | ; 47 | { | ~ main.c:54:29: error: 'j' undeclared (first use in this function) 54 | b=i-j; | ^ main.c:55:25: error: 'l' undeclared (first use in this function) 55 | l++; | ^ main.c:60:1: error: expected declaration or statement at end of input 60 | } | ^
s935696628
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; for (;;) { l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10; g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { for (rina=0;rina<=4;rina++) { m[rina]=h; } } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; for (h=0;h<=10;h++) { if=(g[h]==1) { for (rina=0;rina<=4;rina++) { m[rina]=h; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:5:9: error: 'a' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:9: note: each undeclared identifier is reported only once for each function it appears in main.c:5:11: error: 'b' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:13: error: 'c' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:15: error: 'd' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:17: error: 'e' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:19: error: 'f' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:21: error: 'g' undeclared (first use in this function) 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:5:27: error: expected expression before '{' token 5 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki; | ^ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:31:27: error: expected expression before '[' token 31 | g=[e]=1; | ^ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=10;h<=0;h--) | ^ main.c:38:46: error: 'rina' undeclared (first use in this function) 38 | for (rina=0;rina<=4;rina++) | ^~~~ main.c:40:49: error: 'm' undeclared (first use in this function) 40 | m[rina]=h; | ^ main.c:43:33: error: 'i' undeclared (first use in this function) 43 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:45:30: error: expected expression before '{' token 45 | m[4]={0}; | ^ main.c:48:35: error: expected '(' before '=' token 48 | if=(g[h]==1) | ^ | ( main.c:48:45: error: expected ';' before '{' token 48 | if=(g[h]==1) | ^ | ; 49 | { | ~ main.c:56:29: error: 'j' undeclared (first use in this function) 56 | b=i-j; | ^ main.c:62:1: error: expected declaration or statement at end of input 62 | } | ^
s487733478
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10; g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { m[suki]=h; suki++; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki++; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[10]={0},n,rina,suzuki,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:31:27: error: expected expression before '[' token 31 | g=[e]=1; | ^ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=10;h<=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s169885966
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10; g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { m[suki]=h; suki++; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki++; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:31:27: error: expected expression before '[' token 31 | g=[e]=1; | ^ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=10;h<=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s461065256
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10;0. g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { m[suki]=h; suki++; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki++; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:30:53: error: expected ';' before 'g' 30 | e=(b-(1000*c)-(100*d))/10;0. | ^ | ; 31 | g=[e]=1; | ~ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=10;h<=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s162035370
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10;0. g=[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=10;h<=0;h--) { if (g[h]==1) { m[suki]=h; suki++; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki++; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:30:53: error: expected ';' before 'g' 30 | e=(b-(1000*c)-(100*d))/10;0. | ^ | ; 31 | g=[e]=1; | ~ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=10;h<=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s749603179
p00254
C
#include<stdio.h> int main(){ int n; scanf("%d",&n); while(n!=0000){ int a[4]={0},l[4]={0},s[4]={0},i,j,c=0,t,o; while(n!=6174&&n%1111!=0){ a[0]=n/1000; n=n%1000; a[1]=n/100; n=n%100; a[2]=n/10; n=n%10; a[3]=n; for(i=0;i<=2;i++){ for(j=i+1;j<=3;j++){ if(a[i]<a[j]){ t=a[i]; a[i]=a[j]; a[j]=t; } } } for(i=0;i<=3;i++){ l[i]=a[i]; s[3-i]=a[i]; } n=(l[0]-s[0])*1000+(l[1]-s[1])*100+(l[2]-s[2])*10+l[3]-s[3]; c++; } if(n%1111!=0){ printf("%d",c); scanf("%d",&n); } else if(n==6714){ printf("0\n"); } else{ printf("NA\n"); scanf("%d",&n); } }
main.c: In function 'main': main.c:42:1: error: expected declaration or statement at end of input 42 | } | ^
s727637027
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10;0. g[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=9;h<=0;h--) { if (g[h]==1) { m[suki]=h; suki++; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki++; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l++; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,rina,suzuki,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:30:53: error: expected ';' before 'g' 30 | e=(b-(1000*c)-(100*d))/10;0. | ^ | ; 31 | g[e]=1; | ~ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=9;h<=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s212975939
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10;0. g[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=9;h>=0;h--) { if (g[h]==1) {11:10 2017/08/25 m[suki]=h; suki=suki+1; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki=suki+1; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l=l+1; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:30:53: error: expected ';' before 'g' 30 | e=(b-(1000*c)-(100*d))/10;0. | ^ | ; 31 | g[e]=1; | ~ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=9;h>=0;h--) | ^ main.c:37:36: error: expected ';' before ':' token 37 | {11:10 2017/08/25 | ^ | ; main.c:37:45: error: invalid digit "8" in octal constant 37 | {11:10 2017/08/25 | ^~ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:41:35: error: 'm' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s295834818
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10;0. g[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=9;h>=0;h--) { if (g[h]==1) { m[suki]=h; suki=suki+1; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki=suki+1; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l=l+1; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:30:53: error: expected ';' before 'g' 30 | e=(b-(1000*c)-(100*d))/10;0. | ^ | ; 31 | g[e]=1; | ~ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=9;h>=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:43:30: error: expected expression before '{' token 43 | m[4]={0}; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s214940684
p00254
C
#include <stdio.h> int main(void) { a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; for (;;) { suki=0; l=0; k=0; b=0; scanf("%d",&b); if (b==0000) { break 0; } if (b==6174) { printf("0\n"); } if (b%1111==0) { printf("NA\n"); } if (b!=6174) { c=b/1000; g[c]=1; d=(b-(1000*c))/100; g[d]=1; e=(b-(1000*c)-(100*d))/10;0. g[e]=1; f=b-(1000*c)-(100*d)-(10*e); g[f]=1; for (h=9;h>=0;h--) { if (g[h]==1) { m[suki]=h; suki=suki+1; } i=m[0]*1000+m[1]*100+m[2]*10+m[3]; } int m[4]={0}; suki=0; for (h=0;h<=10;h++) { if=(g[h]==1) { m[suki]=h; suki=suki+1; } } j=m[0]*1000+m[1]*100+m[2]*10+m[3]; b=i-j; l=l+1; } printf("&d\n",l); } return 0; }
main.c: In function 'main': main.c:4:9: error: 'a' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:9: note: each undeclared identifier is reported only once for each function it appears in main.c:4:11: error: 'b' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:13: error: 'c' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:15: error: 'd' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:17: error: 'e' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:19: error: 'f' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:21: error: 'g' undeclared (first use in this function) 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:4:27: error: expected expression before '{' token 4 | a,b,c,d,e,f,g[10]={0},h,i,j,k,l,m[4]={0},n,suki; | ^ main.c:7:17: error: 'suki' undeclared (first use in this function) 7 | suki=0; | ^~~~ main.c:8:17: error: 'l' undeclared (first use in this function) 8 | l=0; | ^ main.c:9:17: error: 'k' undeclared (first use in this function) 9 | k=0; | ^ main.c:14:30: error: expected ';' before numeric constant 14 | break 0; | ^~ | ; main.c:30:53: error: expected ';' before 'g' 30 | e=(b-(1000*c)-(100*d))/10;0. | ^ | ; 31 | g[e]=1; | ~ main.c:34:30: error: 'h' undeclared (first use in this function) 34 | for (h=9;h>=0;h--) | ^ main.c:38:33: error: 'm' undeclared (first use in this function) 38 | m[suki]=h; | ^ main.c:41:33: error: 'i' undeclared (first use in this function) 41 | i=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^ main.c:47:35: error: expected '(' before '=' token 47 | if=(g[h]==1) | ^ | ( main.c:47:45: error: expected ';' before '{' token 47 | if=(g[h]==1) | ^ | ; 48 | { | ~ main.c:53:25: error: 'j' undeclared (first use in this function) 53 | j=m[0]*1000+m[1]*100+m[2]*10+m[3]; | ^
s580285602
p00254
C
#include<stdio.h> #include<algorithm> using namespace std; int main() { int a,n[4],L=0,S=0,i,c=0; scanf("%d",&a); while(a!=0000){ c=0; while(a!=6174){ if(a==1111||a==2222||a==3333||a==4444||a==5555||a==6666||a==7777||a==8888||a==9999){ break; } L=0;S=0; c++; n[0]=a/1000; n[1]=a/100-n[0]*10; n[2]=a/10-n[0]*100-n[1]*10; n[3]=a-n[0]*1000-n[1]*100-n[2]*10; sort(n,n+4); L+=n[3]*1000; L+=n[2]*100; L+=n[1]*10; L+=n[0]; S+=n[0]*1000; S+=n[1]*100; S+=n[2]*10; S+=n[3]; a=L-S; } if(a==1111||a==2222||a==3333||a==4444||a==5555||a==6666||a==7777||a==8888||a==9999){ printf("NA\n"); } else{ printf("%d\n",c); } scanf("%d",&a); } return 0; }
main.c:2:9: fatal error: algorithm: No such file or directory 2 | #include<algorithm> | ^~~~~~~~~~~ compilation terminated.
s198741900
p00254
C
#include<stdio.h> #include<algorithm> using namespace std; int main() { int a,n[4],L=0,S=0,i,c=0; scanf("%d",&a); while(a!=0000){ c=0; while(a!=6174){ if(a==1111||a==2222||a==3333||a==4444||a==5555||a==6666||a==7777||a==8888||a==9999){ break; } L=0;S=0; c++; n[0]=a/1000; n[1]=a/100-n[0]*10; n[2]=a/10-n[0]*100-n[1]*10; n[3]=a-n[0]*1000-n[1]*100-n[2]*10; sort(n,n+4); L+=n[3]*1000; L+=n[2]*100; L+=n[1]*10; L+=n[0]; S+=n[0]*1000; S+=n[1]*100; S+=n[2]*10; S+=n[3]; a=L-S; } if(a==1111||a==2222||a==3333||a==4444||a==5555||a==6666||a==7777||a==8888||a==9999){ printf("NA\n"); } else{ printf("%d\n",c); } scanf("%d",&a); } return 0; }
main.c:2:9: fatal error: algorithm: No such file or directory 2 | #include<algorithm> | ^~~~~~~~~~~ compilation terminated.
s954712992
p00254
C
#include<stdio.h> #include<stdlib.h> int cmp(void const *a,void const *b) { return *(char*)a-*(char*)b; } int main() { int i,x,c; char s[5],t[5]={0}; for(;scanf("%d\n",&x),x;) { if(!(x%1111)) { puts("NA"); continue; } for(c=0;x!=6174;c++) { itoa(x,s,10); qsort(s,4,sizeof(char),cmp); for(i=0;i<4;i++) t[3-i]=s[i]; x=atoi(t)-atoi(s); } printf("%d\n",c); } return 0; }
main.c: In function 'main': main.c:22:25: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration] 22 | itoa(x,s,10); | ^~~~
s045798549
p00254
C++
#include<iostream> using namespace std; int main() { int n,d[4],max,min,w[4]={1000,100,10,1}; int c=0; cin >>n; while(n!=6174) { for(i=0;i<4;i++) { d[i]=n/w[i]; n=n%w[i]; } for(i=0;i<3;i++) { for(j=i+1;j<4;j++) { if(d[i]<d[j]) { tmp=d[i]; d[i]=d[j]; d[j]=tmp; } } } for(i=0;i<4;i++) { max=max+(d[i]*w[i]); min=min+(d[i]*w[3-i]); } n = max-min; c++; } cout << n << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:12: error: 'i' was not declared in this scope 10 | for(i=0;i<4;i++) | ^ a.cc:15:12: error: 'i' was not declared in this scope 15 | for(i=0;i<3;i++) | ^ a.cc:17:15: error: 'j' was not declared in this scope 17 | for(j=i+1;j<4;j++) | ^ a.cc:21:21: error: 'tmp' was not declared in this scope; did you mean 'tm'? 21 | tmp=d[i]; | ^~~ | tm a.cc:27:13: error: 'i' was not declared in this scope 27 | for(i=0;i<4;i++) | ^
s533231493
p00254
C++
#include <cstdio> #include <cstring> #include <string> using namespace std; int main(){ while(1){ int n,l,s; int cnt = 0; string tmp; scanf("%d",&n); if(n == 0)break; if(n % 1111 == 0){ printf("NA\n"); continue; } while(n != 6174){ tmp = to_string(n); sort(tmp.begin(),tmp.end()); s = stoi(tmp); reverse(tmp.begin(),tmp.end()); l = stoi(tmp); n = l - s; cnt++; } printf("%d\n", cnt); } return 0; }
a.cc: In function 'int main()': a.cc:23:25: error: 'sort' was not declared in this scope; did you mean 'short'? 23 | sort(tmp.begin(),tmp.end()); | ^~~~ | short a.cc:26:25: error: 'reverse' was not declared in this scope 26 | reverse(tmp.begin(),tmp.end()); | ^~~~~~~
s127527136
p00254
C++
#include <cstdio> #include <cstring> #include <string> #include <iostream> using namespace std; int main(){ while(1){ int n=0,l,s; int cnt = 0; string tmp; cin >> tmp; n = atoi(tmp.c_str()); if(n == 0)break; if(n % 1111 == 0){ printf("NA\n"); continue; } while(n != 6174){ sort(tmp.begin(),tmp.end()); s = atoi(tmp.c_str()); sort(tmp.begin(),tmp.end(),greater<char>()); l = atoi(tmp.c_str()); n = l - s; for(int i=0,p=1000;i<4;i++,p/=10){ tmp[i] = '0' + n/p; n %= p; } n = atoi(tmp.c_str()); cnt++; } printf("%d\n", cnt); } return 0; }
a.cc: In function 'int main()': a.cc:25:25: error: 'sort' was not declared in this scope; did you mean 'short'? 25 | sort(tmp.begin(),tmp.end()); | ^~~~ | short
s711230406
p00254
C++
#include <cstdio> #include <cstring> #include <string> #include <iostream> #include <algorithm> #include <stdlib> using namespace std; int main(){ while(1){ int n=0,l,s; int cnt = 0; string tmp; cin >> tmp; n = atoi(tmp.c_str()); if(n == 0)break; if(n % 1111 == 0){ printf("NA\n"); continue; } while(n != 6174){ sort(tmp.begin(),tmp.end()); s = atoi(tmp.c_str()); sort(tmp.begin(),tmp.end(),greater<char>()); l = atoi(tmp.c_str()); n = l - s; for(int i=0,p=1000;i<4;i++,p/=10){ tmp[i] = '0' + n/p; n %= p; } n = atoi(tmp.c_str()); cnt++; } printf("%d\n", cnt); } return 0; }
a.cc:6:10: fatal error: stdlib: No such file or directory 6 | #include <stdlib> | ^~~~~~~~ compilation terminated.
s894154024
p00254
C++
while 1: N = input() if N=='0000':break if N[0] ==N[1] == N[2] == N[3]: print('NA') continue cnt = 0 while N != '6174': x = int(''.join(reversed(sorted(list(N))))) - int(''.join(sorted(list(N)))) N = str(x).zfill(4) cnt += 1 print(cnt)
a.cc:3:11: warning: multi-character character constant [-Wmultichar] 3 | if N=='0000':break | ^~~~~~ a.cc:5:15: warning: multi-character character constant [-Wmultichar] 5 | print('NA') | ^~~~ a.cc:8:16: warning: multi-character character constant [-Wmultichar] 8 | while N != '6174': | ^~~~~~ a.cc:9:17: error: empty character constant 9 | x = int(''.join(reversed(sorted(list(N))))) - int(''.join(sorted(list(N)))) | ^~ a.cc:9:59: error: empty character constant 9 | x = int(''.join(reversed(sorted(list(N))))) - int(''.join(sorted(list(N)))) | ^~ a.cc:1:1: error: expected unqualified-id before 'while' 1 | while 1: | ^~~~~
s622635301
p00254
C++
#include <iostream> #include <cstdio> #include <string> #include <sstream> #include <algorithm> #include <math.h> #include <map> #include <iomanip> #include <vector> #include <queue> #include <set> #include <typeinfo> #define PI 3.14159265359 #define INF 99999999; #define rep(i, n) for(int i=0; i<n; i++) #define REP(n) rep(i, n) #define EPS 1e-10 typedef long long ll; using namespace std; /* class Target { public: vector <string> draw(int n) { } }; */ int main() { for (char s[5]; scanf("%s", s), strcmp(s, "0000")!=0;) { if (count(s, s + 4, s[0]) == 4) { cout << "NA" << endl; continue; } int ans = 0; while (strcmp(s, "6174") != 0) { char s1[5]; strcpy(s1, s); sort(s1, s1 + 4); char s2[5]; strcpy(s2, s); sort(s2, s2 + 4, greater<char>()); int a1 = atoi(s1); int a2 = atoi(s2); sprintf(s, "%04d", a2 - a1); ans++; } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:38:41: error: 'strcmp' was not declared in this scope 38 | for (char s[5]; scanf("%s", s), strcmp(s, "0000")!=0;) | ^~~~~~ a.cc:12:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include <set> +++ |+#include <cstring> 12 | #include <typeinfo> a.cc:50:25: error: 'strcpy' was not declared in this scope 50 | strcpy(s1, s); | ^~~~~~ a.cc:50:25: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s444746246
p00254
C++
#include <iostream> //#include <cstdio> #include <stdio.h> #include <string> #include <sstream> #include <algorithm> #include <math.h> #include <map> #include <iomanip> #include <vector> #include <queue> #include <set> #include <typeinfo> #define PI 3.14159265359 #define INF 99999999; #define rep(i, n) for(int i=0; i<n; i++) #define REP(n) rep(i, n) #define EPS 1e-10 typedef long long ll; using namespace std; /* class Target { public: vector <string> draw(int n) { } }; */ int main() { for (char s[5]; scanf("%s", s), strcmp(s, "0000")!=0;) { if (count(s, s + 4, s[0]) == 4) { cout << "NA" << endl; continue; } int ans = 0; while (strcmp(s, "6174") != 0) { char s1[5]; strcpy(s1, s); sort(s1, s1 + 4); char s2[5]; strcpy(s2, s); sort(s2, s2 + 4, greater<char>()); int a1 = atoi(s1); int a2 = atoi(s2); sprintf(s, "%04d", a2 - a1); ans++; } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:39:41: error: 'strcmp' was not declared in this scope 39 | for (char s[5]; scanf("%s", s), strcmp(s, "0000")!=0;) | ^~~~~~ a.cc:13:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 12 | #include <set> +++ |+#include <cstring> 13 | #include <typeinfo> a.cc:51:25: error: 'strcpy' was not declared in this scope 51 | strcpy(s1, s); | ^~~~~~ a.cc:51:25: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s207649781
p00254
C++
#include<iostream> #include<cmath> #include<algorithm> #include<string> using namespace std; int N,a[4],S.L,count; int main(){ while(1){ count=0; cin>>N; if(N==0){break;} if(N%1111==0){ cout<<"NA"<<endl; continue; } while(N!=6174){ a[0]=N/1000; a[1]=(N%1000)/100; a[2]=(N%100)/10; a[3]=N%10; sort(a,a+4); L=a[3]*1000+a[2]*100+a[1]*10+a[0]; S=a[0]*1000+a[1]*100+a[2]*10+a[3]; N=L-S; count++; } cout<<count<<endl; } return 0; }
a.cc:7:13: error: expected initializer before '.' token 7 | int N,a[4],S.L,count; | ^ a.cc: In function 'int main()': a.cc:11:23: error: overloaded function with no contextual type information 11 | count=0; | ^ a.cc:24:25: error: 'L' was not declared in this scope 24 | L=a[3]*1000+a[2]*100+a[1]*10+a[0]; | ^ a.cc:25:25: error: 'S' was not declared in this scope 25 | S=a[0]*1000+a[1]*100+a[2]*10+a[3]; | ^ a.cc:27:30: error: no post-increment operator for type 27 | count++; | ^~ a.cc:29:21: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>') 29 | cout<<count<<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) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no
s585831397
p00254
C++
#include <iostream> using namespace std; int main(){ while(1){ int count=0; int N; cin>>N; if(N==0) break; if(N%1111==0){ cout<<"NA"<<endl; continue; } int L,S; while(N!=6174){ int n[4]; n[0]=N/1000; n[1]=N/100%10; n[2]=N/10%10; n[3]=N%10; sort(n,n+4); L=1000*n[3]+100*n[2]+10*n[1]+n[0]; S=1000*n[0]+100*n[1]+10*n[2]+n[3]; N=L-S; count++; } cout<<count<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:3: error: 'sort' was not declared in this scope; did you mean 'short'? 23 | sort(n,n+4); | ^~~~ | short
s378320238
p00254
C++
#include<iostream> #include<algorithm> #include<functional> #include<cstring> #include<cstdlib> int main() { char str[4]; while (std::cin >> str) { if (str[0] == str[1] == str[2] == str[3]) { if (str[0] == '0') break; else std::cout << "NA" << std::endl; } char l[4], s[4]; int cnt = 0; while(str!="6174") { ++cnt; std::memcpy(l, str, 4); std::memcpy(s, str, 4); std::sort(l, l + 4, std::greater<char>()); std::sort(s, s + 4); int a = atoi(l) - atoi(s); itoa(a, str, 10); } std::cout << cnt << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:25: error: 'itoa' was not declared in this scope 25 | itoa(a, str, 10); | ^~~~
s108890164
p00254
C++
#include<iostream> #include<algorithm> #include<functional> #include<cstring> #include<cstdlib> int main() { char str[4]; while (std::cin >> str) { if (str[0] == str[1] == str[2] == str[3]) { if (str[0] == '0') break; else std::cout << "NA" << std::endl; } char l[4], s[4]; int cnt = 0; while(str!="6174") { ++cnt; std::memcpy(l, str, 4); std::memcpy(s, str, 4); std::sort(l, l + 4, std::greater<char>()); std::sort(s, s + 4); int a = atoi(l) - atoi(s); itoa(a, str, 10); } std::cout << cnt << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:25: error: 'itoa' was not declared in this scope 25 | itoa(a, str, 10); | ^~~~
s530519581
p00254
C++
#include<stdio.h> int main (){ int N[4],L,S,c,i,a; while(1){ for(i=0;i!=4;i++){ scanf("%1d",&N[i]); } if(N[0]==N[1]&&N[2]==N[3]&&N[1]==N[2]){ if(N[1]==0) break; else puts("NA"); } else{ for(i=0;c!=6174;i++){ for(S=0;S!=4;S++){ for(a=S;a!=4;a++){ if(N[S]<N[a]){ c=N[a]; N[a]=N[S]; N[S]=c; } } } L=1000*N[0]+100*N[1]+10*N[2]+N[3]; S=1000*N[3]+100*N[2]+10*N[1]+N[0]; L-=S; c=L; N[0]=L/1000; L%=1000; N[1]=L/100; L%=100; N[2]=L/10; L%=10; N[3]=L; } printf("%d\n",i); } } } #include<stdio.h> int main (){ int N[4],L,S,c,i,a; while(1){ for(i=0;i!=4;i++){ scanf("%1d",&N[i]); } if(N[0]==N[1]&&N[2]==N[3]&&N[1]==N[2]){ if(N[1]==0) break; else puts("NA"); } else{ for(i=0;c!=6174;i++){ for(S=0;S!=4;S++){ for(a=S;a!=4;a++){ if(N[S]<N[a]){ c=N[a]; N[a]=N[S]; N[S]=c; } } } L=1000*N[0]+100*N[1]+10*N[2]+N[3]; S=1000*N[3]+100*N[2]+10*N[1]+N[0]; L-=S; c=L; N[0]=L/1000; L%=1000; N[1]=L/100; L%=100; N[2]=L/10; L%=10; N[3]=L; } printf("%d\n",i); } } }
a.cc:43:5: error: redefinition of 'int main()' 43 | int main (){ | ^~~~ a.cc:2:5: note: 'int main()' previously defined here 2 | int main (){ | ^~~~
s921082623
p00254
C++
#include<stdio.h> int main (){ int N[4],L,S,c,i,a; while(1){ for(i=0;i!=4;i++){ scanf("%1d",&N[i]); } if(N[0]==N[1]&&N[2]==N[3]&&N[1]==N[2]){ if(N[1]==0) break; else puts("NA"); } else{ for(i=0;c!=6174;i++){ for(S=0;S!=4;S++){ for(a=S;a!=4;a++){ if(N[S]<N[a]){ c=N[a]; N[a]=N[S]; N[S]=c; } } } L=1000*N[0]+100*N[1]+10*N[2]+N[3]; S=1000*N[3]+100*N[2]+10*N[1]+N[0]; L-=S; c=L; N[0]=L/1000; L%=1000; N[1]=L/100; L%=100; N[2]=L/10; L%=10; N[3]=L; } printf("%d\n",i); } } } #include<stdio.h> int main (){ int N[4],L,S,c,i,a; while(1){ for(i=0;i!=4;i++){ scanf("%1d",&N[i]); } if(N[0]==N[1]&&N[2]==N[3]&&N[1]==N[2]){ if(N[1]==0) break; else puts("NA"); } else{ for(i=0;c!=6174;i++){ for(S=0;S!=4;S++){ for(a=S;a!=4;a++){ if(N[S]<N[a]){ c=N[a]; N[a]=N[S]; N[S]=c; } } } L=1000*N[0]+100*N[1]+10*N[2]+N[3]; S=1000*N[3]+100*N[2]+10*N[1]+N[0]; L-=S; c=L; N[0]=L/1000; L%=1000; N[1]=L/100; L%=100; N[2]=L/10; L%=10; N[3]=L; } printf("%d\n",i); } } return 0; }
a.cc:43:5: error: redefinition of 'int main()' 43 | int main (){ | ^~~~ a.cc:2:5: note: 'int main()' previously defined here 2 | int main (){ | ^~~~
s793260879
p00254
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { int m, n[4], mi[4], ma[4], na; int max_int, min_int, n_int, ans; bool same = false; while (scanf("%1d", &n[i])){ na = n[0]; for (int i = 1; i < 4; i++){ if (na != n[i]) same = true; } if (!same) cout << "NA" << endl; while(n[0] != 6 || n[1] != 1 || n[2] != 7 || n[3] != 4){ if (!same) break; sort(n, n + 4); for (int i = 0; i < 4; i++){ mi[i] = n[i]; ma[3 - i] = n[i]; } for (int i = 0; i < 4; i++){ max_int = ma[i] * 10 ^ i; min_int = mi[i] * 10 ^ i; } n_int = max_int - min_int; for (int i = 0; i < 4; i++){ n[i] = n_int / (10 ^ (3 - i)) % 10; } ans++; } if (!same) cout << ans << endl; } return (0); }
a.cc: In function 'int main()': a.cc:12:48: error: 'i' was not declared in this scope; did you mean 'mi'? 12 | while (scanf("%1d", &n[i])){ | ^ | mi
s502855087
p00254
C++
#include <bits/stdc++.h> using namespace std; typedef long int lint; typedef long long int llint; typedef pair<int, int> pii; typedef pair<int, string> pis; typedef pair<long, long> pll; #define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define ALL(c) (c).begin(), (c).end() #define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i) #define REP(i, n) FOR(i, 0, n) #define endl '\n' #define mod 1000000007 #define INF 100000000 #define fk first #define sv second const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; template<typename T> void print(const std::vector<T>& v, char sep=' ') { for (int i = 0; i < (int)v.size(); i++) { if (i != 0) cout << sep; cout << v[i]; } cout << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; while (cin >> n){ int ct = 0; if (n % 1111 == 0){ cout << "NA\n"; continue; } while (n != 6174){ int l, s, num[4]; REP(i, 4){ num[i] = n % 10; n /= 10; } sort(n, n + 4); l = s = 0; REP(i, 4){ s = n * 10 + num[3 - i]; l = n * 10 + num[i]; } n = l - s; ct++; } cout << ct << endl; } }
In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:11: required from here 49 | sort(n, n + 4); | ~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1780:17: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1780 | __val = _GLIBCXX_MOVE(*__i); | ^~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60: /usr/include/c++/14/bits/stl_algo.h:1780:25: error: invalid type argument of unary '*' (have 'int') 1780 | __val = _GLIBCXX_MOVE(*__i); | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1782:15: error: invalid type argument of unary '*' (have 'int') 1782 | *__first = _GLIBCXX_MOVE(__val); | ^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:71: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:11: required from here 49 | sort(n, n + 4); | ~~~~^~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:16: error: invalid type argument of unary '*' (have 'int') 45 | { return *__it1 < *__it2; } | ^~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:25: error: invalid type argument of unary '*' (have 'int') 45 | { return *__it1 < *__it2; } | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algo.h:61: /usr/include/c++/14/bits/stl_heap.h: In instantiation of 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1905 | std::__introsort_loop(__first, __last, | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:11: required from here 49 | sort(n, n + 4); | ~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:344:11: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 344 | _ValueType; | ^~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:346:11: error: no type named 'difference_type' in 'struct std::iterator_traits<int>' 346 | _DistanceType; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:1596:19: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1596 | std::__pop_heap(__first, __middle, __i, __comp); | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1868 | std::__heap_select(__first, __middle, __last, __comp); | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1884 | std::__partial_sort(__first, __last, __last, __comp); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1905 | std::__introsort_loop(__first, __last, | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1907 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:49:11: required from here 49 | sort(n, n + 4); | ~~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:258:9: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 258 | _ValueType; | ^~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:260:9: error: no type named 'difference_type' in 'struct std::iterator_traits<int>' 260 | _DistanceType; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:262:28: error: invalid type argument of unary '*' (have 'int') 262 | _ValueType __value = _GLIBCXX_MOVE(*__result); | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:263:7: error: invalid type argument of unary '*' (have 'int') 263 | *__result = _GLIBCXX_MOVE(*__first); | ^~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:263:19: error
s738175930
p00254
C++
#include <bits/stdc++.h> using namespace std; int rec(string N, int cnt) { vector<char> LN(4), SN(4); int L = 0, S = 0; for (int i = 0; i < 4; i++) { LN[i] = SN[i] = N[i] - '0'; } sort(ALL(LN)); sort(ALL(SN)); for (int i = 0; i < 4; i++) { L *= 10; S *= 10; L += LN[3 - i]; S += SN[i]; } return (L - S == 6174) ? cnt + 1 : rec(to_string(L - S), cnt + 1); } signed main() { string N; while (cin >> N, N != "0000") { if (N[0] == N[1] and N[2] == N[3] and N[0] == N[2]) print("NA"); else if (N == "6174") print("0"); else print(rec(N, 0)); } return (0); }
a.cc: In function 'int rec(std::string, int)': a.cc:10:8: error: 'ALL' was not declared in this scope 10 | sort(ALL(LN)); | ^~~ a.cc: In function 'int main()': a.cc:25:57: error: 'print' was not declared in this scope; did you mean 'rint'? 25 | if (N[0] == N[1] and N[2] == N[3] and N[0] == N[2]) print("NA"); | ^~~~~ | rint a.cc:26:27: error: 'print' was not declared in this scope; did you mean 'rint'? 26 | else if (N == "6174") print("0"); | ^~~~~ | rint a.cc:27:10: error: 'print' was not declared in this scope; did you mean 'rint'? 27 | else print(rec(N, 0)); | ^~~~~ | rint
s507618789
p00254
C++
//============================================================================ // Name : AOJ.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> #include <cstdio> #include <string> #include <cctype> using namespace std; int main() { string n,L,S; int R=0; while(1){ cin>>n; if(n=="0000")break; if(n=="6174")cout<<"0"<<endl; L=S=n; sort(L.begin(),L.end(),greater<char>()); sort(S.begin(),S.end()); cout<<R<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:17: error: 'sort' was not declared in this scope; did you mean 'short'? 23 | sort(L.begin(),L.end(),greater<char>()); | ^~~~ | short
s044271203
p00254
C++
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin>>s){ if(s=="0000")break; int ans=0; if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){ ans=-1; goto FIN; } while(s=="6174"){ string sa,sb; char ca[4]={s[0],s[1],s[2],s[3]}; sort(ca,ca+4); for(int i=0;i<4;i++){ sa.push_back(s[i]); sb.push_back(s[3-i]); } int a=stoi(sa); int b=stoi(sb); int c=abs(a-b); string sc=to_string(c); for(int i=0;i<4-sc.size();i++)sc.insert(0,'0'); s=sc; ans++; } FIN: if(ans==-1)cout<<"NA"<<endl; else cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:26:64: error: no matching function for call to 'std::__cxx11::basic_string<char>::insert(int, char)' 26 | for(int i=0;i<4-sc.size();i++)sc.insert(0,'0'); | ~~~~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/basic_string.h:2007:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match) 2007 | insert(size_type __pos, const _CharT* __s) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:2007:7: note: conversion of argument 2 would be ill-formed: a.cc:26:67: error: invalid conversion from 'char' to 'const char*' [-fpermissive] 26 | for(int i=0;i<4-sc.size();i++)sc.insert(0,'0'); | ^~~ | | | char /usr/include/c++/14/bits/basic_string.h:1876:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 1876 | insert(const_iterator __p, _InputIterator __beg, _InputIterator __end) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1876:9: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:2069:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 2069 | insert(size_type __pos, const _Tp& __svt) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:2069:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]': /usr/include/c++/14/bits/basic_string.h:149:8: required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 149 | using _If_sv = enable_if_t< | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:2069:2: required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::insert(size_type, const _Tp&) [with _Tp = char]' 2069 | insert(size_type __pos, const _Tp& __svt) | ^~~~~~ a.cc:26:43: required from here 26 | for(int i=0;i<4-sc.size();i++)sc.insert(0,'0'); | ~~~~~~~~~^~~~~~~ /usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>' 2711 | using enable_if_t = typename enable_if<_Cond, _Tp>::type; | ^~~~~~~~~~~ /usr/include/c++/14/bits/basic_string.h:2086:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' 2086 | insert(size_type __pos1, const _Tp& __svt, | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:2086:9: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:1831:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]' 1831 | insert(const_iterator __p, size_type __n, _CharT __c) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1831:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:1911:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; const_iterator = std::__cxx11::basic_string<char>::const_iterator]' 1911 | insert(const_iterator __p, initializer_list<_CharT> __l) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1911:29: note: no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::const_iterator' 1911 | insert(const_iterator __p, initializer_list<_CharT> __l) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/basic_string.h:1939:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 1939 | insert(size_type __pos1, const basic_string& __str) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1939:52: note: no known conversion for argument 2 from 'char' to 'const std::__cxx11::basic_string<char>&' 1939 | insert(size_type __pos1, const basic_string& __str) | ~~~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/bits/basic_string.h:1963:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 1963 | insert(size_type __pos1, const basic_string& __str, | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1963:7: note: candidate expects 4 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:1987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 1987 | insert(size_type __pos, const _CharT* __s, size_type __n) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:1987:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:2032:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' 2032 | insert(size_type __pos, size_type __n, _CharT __c) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:2032:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/basic_string.h:2051:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(__const_iterator, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]' 2051 | insert(__const_iterator __p, _CharT __c) | ^~~~~~ /usr/include/c++/14/bits/basic_string.h:2051:31: note: no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'} 2051 | insert(__const_iterator __p, _CharT __c) | ~~~~~~~~~~~~~~~~~^~~
s871077554
p00254
C++
#include<iostream> #include<algorithm> using namespace std; int solve(int num,int& cnt) { if (num == 6174)return cnt; cnt++; int s[5]; for (int i = 0; i < 4; i++) { s[i] = num % 10; num -= s[i]; num /= 10; } sort(s, s + 4); return solve((s[3] - s[0]) * 999 + (s[2] - s[1]) * 90), cnt); } int main() { int n; while (cin >> n) { if (!n)return 0; else if (n % 1111 == 0) { cout << "NA\n"; continue; } int cnt; solve(n, cnt); cout << cnt << endl; } }
a.cc: In function 'int solve(int, int&)': a.cc:14:21: error: too few arguments to function 'int solve(int, int&)' 14 | return solve((s[3] - s[0]) * 999 + (s[2] - s[1]) * 90), cnt); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:4:5: note: declared here 4 | int solve(int num,int& cnt) { | ^~~~~ a.cc:14:68: error: expected ';' before ')' token 14 | return solve((s[3] - s[0]) * 999 + (s[2] - s[1]) * 90), cnt); | ^ | ; a.cc:14:68: error: expected primary-expression before ')' token
s794726885
p00254
C++
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (;;) { int n=sc.nextInt(); if(n==0) { break; } Integer[] l=d(n); if(l[0]==l[1]&&l[1]==l[2]&&l[2]==l[3]) { System.out.println("NA"); continue; } int c=0; while(n!=6174) { c++; l=d(n); Arrays.sort(l,Comparator.reverseOrder()); int a=c(l); Arrays.sort(l); int b=c(l); n=a-b; } System.out.println(c); } } static int c(Integer[] l) { int n=0; for(int i=0,j=1000;i<4;i++,j/=10) { n+=l[i]*j; } return n; } static Integer[] d(int n) { Integer[] l=new Integer[4]; for(int i=0,j=1000;i<4;i++,j/=10) { l[i]=n/j; n%=j; } return l; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Arrays; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Comparator; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Scanner; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s601629476
p00254
C++
#include<cstdio> #include<cstdlib> #include<cmath> #include<algorithm> #include<Windows.h> using namespace std; int main(){ char num[6]={0}; while(1){ int cnt = 0; scanf("%s",num); if(num[0] == num[1] && num[1] == num[2] && num[2] == num[3]){ if(num[0] == 48)break; else puts("NA"); continue; } if(num[0] == '6' && num[1] == '1' && num[2] == '7' && num[3] == '4'){ puts("0"); continue; } while(1){ sort(num,num+4); int s = atoi(num); reverse(num,num+4); int l = atoi(num); int x = 0; if(l - s == 6174){ printf("%d\n",cnt+1); break; } else{ x = l - s; cnt++; for(int i = 0; i < 4; i++){ num[i] = (x / pow(10,3-i))+48; x -= (num[i]-48) * pow(10,3-i); } } } } return 0; }
a.cc:5:9: fatal error: Windows.h: No such file or directory 5 | #include<Windows.h> | ^~~~~~~~~~~ compilation terminated.
s707375151
p00254
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int main(){ int n; while(scanf("%d",&n)n){ int cnt = 0; bool flg = 0; while(1){ if(n == 6174)break; if(n%1111 == 0){ flg = 1; break; } int a[4]={0}; a[0] = n/1000; a[1] = (n%1000)/100; a[2] = (n%100)/10; a[3] = n%10; int L[4],S[4]; sort(a,a+4); for(int i = 0; i < 4; i++){ L[3-i] = S[i] = a[i]; } int l=0,s=0; for(int i = 0; i < 4; i++){ l += L[3-i] * pow(10,i); s += S[3-i] * pow(10,i); } n = l - s; cnt++; } if(flg)puts("NA"); else printf("%d\n",cnt); } return 0; }
a.cc: In function 'int main()': a.cc:8:25: error: expected ')' before 'n' 8 | while(scanf("%d",&n)n){ | ~ ^ | ) a.cc:8:26: error: expected ';' before ')' token 8 | while(scanf("%d",&n)n){ | ^ | ;
s335299965
p00254
C++
#include <stdio.h> #include <algorithm> using namespace std; bool input(int a[]){ int i, inp; scanf("%d",&inp); if(inp == 0) return false; for(i = 4;i >= 0;i--){ a[i] = inp % 10; inp /= 10; } return true; } int main(void){ int a[4], b[4], i, count; const int suc[4] = {6,1,7,4}; while(input(a)){ count = 0; while(1){ for(i = 0;i < 4;i++) if(suc[i] != a[i]) break; if(i == 4){ printf("%d\n",count); break; } for(i = 1;i < 4;i++) if(a[0] != a[i]) break; if(i == 4){ printf("NA\n"); break; } for(i = 0;i < 4;i++) b[i] = a[i]; sort(a,a + 4); sort(b,b + 4,greater<int>); for(i = 4;i >= 0;i--){ a[i] -= b[i]; if(a[i] < 0){ a[i - 1]--; a[i] += 10; } } count++; } } return 0; }
a.cc: In function 'int main()': a.cc:38:29: error: 'greater' was not declared in this scope 38 | sort(b,b + 4,greater<int>); | ^~~~~~~ a.cc:38:37: error: expected primary-expression before 'int' 38 | sort(b,b + 4,greater<int>); | ^~~
s001781462
p00254
C++
#include <iostream> #include <string> using namespace std; int d[4]; string in; int data[10000]; void solve(){ bool f = true; for(int i=1;i<4;i++) if(in[0] != in[i]) f = false; if(f) cout << "NA" << endl; else{ int ans = 0; for(int i=0;i<4;i++) d[i] = in[i] - '0'; while(1){ if(d[0] == 6 && d[1] == 1 && d[2] == 7 && d[3] == 4) break; int l = 0, s = 0; sort(d, d+4); for(int i=0;i<4;i++){ s *= 10; s += d[i]; l *= 10; l += d[3-i]; } ans++; int tmp = l - s; if(data[tmp] != -1){ ans += data[tmp]; break; } for(int i=0;i<4;i++){ d[3-i] = tmp % 10; tmp /= 10; } } int tmp = 0; for(int i=0;i<4;i++){ tmp *= 10; tmp += d[3-i]; } data[tmp] = ans; cout << ans << endl; } } main(){ fill(data, data+10000, -1); while(cin >> in){ if(in == "0000") break; solve(); } }
a.cc: In function 'void solve()': a.cc:20:7: error: 'sort' was not declared in this scope; did you mean 'short'? 20 | sort(d, d+4); | ^~~~ | short a.cc:29:10: error: reference to 'data' is ambiguous 29 | if(data[tmp] != -1){ | ^~~~ In file included from /usr/include/c++/14/string:53, 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/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:8:5: note: 'int data [10000]' 8 | int data[10000]; | ^~~~ a.cc:30:16: error: reference to 'data' is ambiguous 30 | ans += data[tmp]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:8:5: note: 'int data [10000]' 8 | int data[10000]; | ^~~~ a.cc:43:5: error: reference to 'data' is ambiguous 43 | data[tmp] = ans; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:8:5: note: 'int data [10000]' 8 | int data[10000]; | ^~~~ a.cc: At global scope: a.cc:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 48 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:49:8: error: reference to 'data' is ambiguous 49 | fill(data, data+10000, -1); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:8:5: note: 'int data [10000]' 8 | int data[10000]; | ^~~~ a.cc:49:14: error: reference to 'data' is ambiguous 49 | fill(data, data+10000, -1); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:8:5: note: 'int data [10000]' 8 | int data[10000]; | ^~~~
s385020330
p00254
C++
#include<iostream> #include<string> #include<sstream> #include<cmath> using namespace std; bool allsame(int n){ int tmp=n%10; n/=10; while(n!=0){ if(tmp!=n%10){ return 0; } tmp=n%10; n/=10; } return 1; } string toSortString(int n){ stringstream ss; ss<<n; string tmp; ss>>tmp; sort(tmp.begin(),tmp.end()); return tmp; } int make_l(string s){ int res=0; for(int i=0;i<s.size();i++){ res+=(s[i]-'0')*pow(double(10),i); } return res; } int make_s(string s){ int res=0; for(int i=0;i<s.size();i++){ res+=(s[s.size()-1-i]-'0')*pow(double(10),i); } return res; } int main(){ int n; int ans=0; while(cin>>n,n!=0){ if(allsame(n)){ cout<<"NA"<<endl; continue; } while(n!=6174){ ans++; int l,s; string tmp_n=toSortString(n); l=make_l(tmp_n); s=make_s(tmp_n); n=l-s; } if(n==6174){ cout<<ans<<endl; } } }
a.cc: In function 'std::string toSortString(int)': a.cc:26:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 26 | sort(tmp.begin(),tmp.end()); | ^~~~ | sqrt
s930399413
p00254
C++
#include<iostream> #include<string> #include<sstream> #include<cmath> #include<algorithm> #include<cassert> using namespace std; bool allsame(int n){ int tmp=n%10; n/=10; while(n!=0){ if(tmp!=n%10){ return 0; } tmp=n%10; n/=10; } return 1; } string toSortString(int n){ string res="0000"; int tmp[4]={0,0,0,0}; for(int i=0;n!=0;i++){ tmp[i]=n%10; n/=10; } for(int i=0;i<4;i++){ res[i]=tmp[i]+'0'; } sort(res.begin(),res.end()); return res; } int make_l(string s){ int res=0; for(int i=0;i<s.size();i++){ res+=(s[i]-'0')*pow(double(10),i); } return res; } int make_s(string s){ int res=0; for(int i=0;i<s.size();i++){ res+=(s[s.size()-1-i]-'0')*pow(double(10),i); } return res; } int main(){ int n; int ans=0; while(cin>>n,n!=0){ while(n!=6174){ if(allsame(n)){ cout<<"NA"<<endl; break; } ans++; int l,s; string tmp_n=toSortString(n); l=make_l(tmp_n); s=make_s(tmp_n); n=l-s; assert(ans<=7);
a.cc: In function 'int main()': a.cc:68:22: error: expected '}' at end of input 68 | assert(ans<=7); | ^ a.cc:57:19: note: to match this '{' 57 | while(n!=6174){ | ^ a.cc:68:22: error: expected '}' at end of input 68 | assert(ans<=7); | ^ a.cc:56:21: note: to match this '{' 56 | while(cin>>n,n!=0){ | ^ a.cc:68:22: error: expected '}' at end of input 68 | assert(ans<=7); | ^ a.cc:53:11: note: to match this '{' 53 | int main(){ | ^
s980065702
p00254
C++
#include<iostream> #include<algorithm> #include<functional> #include<string> #include<boost/lexical_cast.hpp> using namespace std; int main(){ while(1){ string N, L, S; cin >> N; if(N == "0000") break; int ans = 0; while(1){ if(N == "6174"){ cout << ans << endl; break; } L = N; S = N; sort(L.begin(), L.end(), greater<char>()); sort(S.begin(), S.end()); if(L == S){ cout << "NA" << endl; break; } int n = boost::lexical_cast<int>(L) - boost::lexical_cast<int>(S); N = boost::lexical_cast<string>(n); ans++; } } return 0; }
a.cc:5:9: fatal error: boost/lexical_cast.hpp: No such file or directory 5 | #include<boost/lexical_cast.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s451025116
p00254
C++
#include<iostream> using namespace std; bool func_a(int *N, int *count); bool main() { int N = 0; int count = 0; bool flag = true; cin >> N; if(N == 6174) { cout << 0 << endl; flag = false; } for(int i = 0; i <= 9; i++) { if(N == i + i * 10 + i * 100 + i * 1000) { cout << "NA" << endl; flag = false; } } if(flag) { while( func_a(&N, &count) ){}; cout << count << endl; } return false; } bool func_a(int *N, int *count) { int num = *N; int Nmax[4]; int Nmin[4]; int L = 0, S = 0; *count += 1; for(int i = 0; i < 4; i++) { Nmax[i] = Nmin[i] = num % 10; num /= 10; } for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { if(Nmax[i] < Nmax[j]) { int tmp = Nmax[i]; Nmax[i] = Nmax[j]; Nmax[j] = tmp; } if(Nmin[i] > Nmin[j]) { int tmp = Nmin[i]; Nmin[i] = Nmin[j]; Nmin[j] = tmp; } } } int dz[4] = {1, 10, 100, 1000}; for(int i= 0; i < 4; i++) { L += Nmax[i] * dz[i]; S += Nmin[i] * dz[i]; } *N = L - S; if(*N == 6174) { return false; } else { return true; } }
a.cc:7:1: error: '::main' must return 'int' 7 | bool main() | ^~~~
s557395939
p00254
C++
#include<iostream> using namespace std; bool func_a(int *N, int *count); bool main() { int N = 0; int count = 0; bool flag = true; cin >> N; if(N == 6174) { cout << 0 << endl; flag = false; } for(int i = 0; i <= 9; i++) { if(N == i + i * 10 + i * 100 + i * 1000) { cout << "NA" << endl; flag = false; } } if(flag) { while( func_a(&N, &count) ){}; cout << count << endl; } return 0; } bool func_a(int *N, int *count) { int num = *N; int Nmax[4]; int Nmin[4]; int L = 0, S = 0; *count += 1; for(int i = 0; i < 4; i++) { Nmax[i] = Nmin[i] = num % 10; num /= 10; } for(int i = 0; i < 4; i++) { for(int j = 0; j < 4; j++) { if(Nmax[i] < Nmax[j]) { int tmp = Nmax[i]; Nmax[i] = Nmax[j]; Nmax[j] = tmp; } if(Nmin[i] > Nmin[j]) { int tmp = Nmin[i]; Nmin[i] = Nmin[j]; Nmin[j] = tmp; } } } int dz[4] = {1, 10, 100, 1000}; for(int i= 0; i < 4; i++) { L += Nmax[i] * dz[i]; S += Nmin[i] * dz[i]; } *N = L - S; if(*N == 6174) { return false; } else { return true; } }
a.cc:7:1: error: '::main' must return 'int' 7 | bool main() | ^~~~
s395527389
p00254
C++
#include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <algorithm> #include <utility> #include <functional> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <climits> #include <fstream> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;} template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();} typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define REP(i,n) FOR(i,0,(n)-1) const double EPS = 1e-12; const double PI = acos(-1.0); const int INF = INT_MAX/10; int main() { string s; while(cin >> s, s!= "0000") { int tmp = toInt(s); if(tmp == 6174) { cout << 0 << endl; goto next; } else if(tmp%1111 == 0) { cout << "NA" << endl; goto next; } int count = 1; while(true) { sort(ALL(s)); int a = toInt(s); sort(RALL(s)); int b = toInt(s); int c = b - a; if(c == 6174) { break; } else { s = toStr(c); count++; } } cout << count << endl; next:; } return 0; }
a.cc: In function 'int main()': a.cc:64:17: error: jump to label 'next' 64 | next:; | ^~~~ a.cc:42:30: note: from here 42 | goto next; | ^~~~ a.cc:48:21: note: crosses initialization of 'int count' 48 | int count = 1; | ^~~~~
s436789420
p00255
Java
package nofill_nosubmit; import java.util.Arrays; import java.util.Scanner; public class AOJ_260 { public static void main(String[] args) { Scanner in=new Scanner(System.in); for(;;) { int n=in.nextInt(); if(n==0) return; int a[]=new int[n];//パイプ int b[]=new int[n-1];//ジョイント int j[]=new int[n-1]; int ans=0; int sum=0; for(int i=0;i<n;i++) { a[i]=in.nextInt(); sum+=a[i]; } for(int i=0;i<n-1;i++) b[i]=in.nextInt(); Arrays.sort(b); for(int i=0;i<n-1;i++)//ジョイントを降順にソート j[i]=b[n-2-i]; //給料=max(パイプの本数*パイプの長さの総和) ans=n*sum; for(int i=0,k=n-1;i<n-1;i++,k--)//i+1がジョイントを使う数 { sum+=j[i]; ans=Math.max(ans,k*sum); } System.out.println(ans); } } public static void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } }
Main.java:4: error: class AOJ_260 is public, should be declared in a file named AOJ_260.java public class AOJ_260 ^ 1 error
s455857916
p00255
Java
import java.util.Scanner; public class pasocon{ public void output(){ int[] p = new int[65000]; int[] j = new int[65000]; int[] k = new int[65000]; Scanner scan = new Scanner(System.in); while(true){ int w = 0; int z = 0; int s = 0; System.out.println("パイプの本数"); int n = scan.nextInt(); if(n == 0)break; for(int i = 0;i < n;i++){ System.out.println("パイプの長さ"); p[i] = scan.nextInt(); } for(int u = 0; u < n - 1;u++){ System.out.println("ジョイントの長さ"); j[u] = scan.nextInt(); } for(int q = 0; q < n;q++){ if(p[q] + p[q+1] < j[q]){ k[q] = p[q] +p[q+1] + j[q]; s = s + k[q]; w = w + 1; q = q + 1; }else{ k[q] = p[q]; w = w + 1; s = s + k[q]; } } for(int d = 1;d < n;d++){ z = s * w; } System.out.println(z); } } public static void main(String[] args){ pasocon p = new pasocon(); p.output(); } }
Main.java:2: error: class pasocon is public, should be declared in a file named pasocon.java public class pasocon{ ^ 1 error
s711864959
p00255
Java
import java.util.Scanner; public class pasocon{ public void output(){ int[] p = new int[65000]; int[] j = new int[65000]; int[] k = new int[65000]; Scanner scan = new Scanner(System.in); while(true){ int w = 0; int z = 0; int s = 0; System.out.println("パイプの本数"); int n = scan.nextInt(); if(n == 0)break; for(int i = 0;i < n;i++){ System.out.println("パイプの長さ"); p[i] = scan.nextInt(); } for(int u = 0; u < n - 1;u++){ System.out.println("ジョイントの長さ"); j[u] = scan.nextInt(); } for(int q = 0; q < n;q++){ if(p[q] + p[q+1] < j[q]){ k[q] = p[q] +p[q+1] + j[q]; s = s + k[q]; w = w + 1; q = q + 1; }else{ k[q] = p[q]; w = w + 1; s = s + k[q]; } } for(int d = 1;d < n;d++){ z = s * w; } System.out.println(z); } } public static void main(String[] args){ pasocon p = new pasocon(); p.output(); } }
Main.java:2: error: class pasocon is public, should be declared in a file named pasocon.java public class pasocon{ ^ 1 error
s924554354
p00255
Java
import java.util.Scanner; public class pasocon{ public void output(){ int[] p = new int[65000]; int[] j = new int[65000]; int[] k = new int[65000]; Scanner scan = new Scanner(System.in); while(true){ int w = 0; int z = 0; int s = 0; System.out.println("パイプの本数"); int n = scan.nextInt(); if(n == 0)break; for(int i = 0;i < n;i++){ System.out.println("パイプの長さ"); p[i] = scan.nextInt(); } for(int u = 0; u < n - 1;u++){ System.out.println("ジョイントの長さ"); j[u] = scan.nextInt(); } for(int q = 0; q < n;q++){ if(p[q] + p[q+1] < j[q]){ k[q] = p[q] +p[q+1] + j[q]; s = s + k[q]; w = w + 1; q = q + 1; }else{ k[q] = p[q]; w = w + 1; s = s + k[q]; } } for(int d = 1;d < n;d++){ z = s * w; } System.out.println(z); } } }
Main.java:2: error: class pasocon is public, should be declared in a file named pasocon.java public class pasocon{ ^ 1 error
s231464161
p00255
Java
import java.util.Scanner; public class pasocon{ public void output(){ int[] p = new int[65000]; int[] j = new int[65000]; int[] k = new int[65000]; Scanner scan = new Scanner(System.in); while(true){ int w = 0; int z = 0; int s = 0; System.out.println("パイプの本数"); int n = scan.nextInt(); if(n == 0)break; for(int i = 0;i < n;i++){ System.out.println("パイプの長さ"); p[i] = scan.nextInt(); } for(int u = 0; u < n - 1;u++){ System.out.println("ジョイントの長さ"); j[u] = scan.nextInt(); } for(int q = 0; q < n;q++){ if(p[q] + p[q+1] < j[q]){ k[q] = p[q] +p[q+1] + j[q]; s = s + k[q]; w = w + 1; q = q + 1; }else{ k[q] = p[q]; w = w + 1; s = s + k[q]; } } for(int d = 1;d < n;d++){ z = s * w; } System.out.println(z); } } public static void main(String[] args){ pasocon p = new pasocon().run(); p.output(); } }
Main.java:2: error: class pasocon is public, should be declared in a file named pasocon.java public class pasocon{ ^ Main.java:42: error: cannot find symbol pasocon p = new pasocon().run(); ^ symbol: method run() location: class pasocon 2 errors
s318997025
p00255
Java
import java.util.*; public class Paipu{ public static void main(String[] args){ int n = 0, p = 0, j = 0, x = 0, y = 0; int psum = 0,jmax = 0, kei = 0, kei2 = 0; int a, b; int[][] hairetu = new int[2][65000]; Scanner scan = new Scanner(System.in); while( true ){ psum = 0; jmax = 0; System.out.println("パイプの本数を入力"); n = scan.nextInt(); if(n == 0) break; x = n; y = n; for(a = 0; a < x; a++){ System.out.println("パイプの長さを入力"); p = scan.nextInt(); hairetu[0][a] = p; psum += p; } for(b = 0; b < y - 1; b++){ System.out.println("ジョイントの長さを入力"); j = scan.nextInt(); hairetu[1][b] = j; if(j > jmax){ jmax = j; } } kei = psum * n; kei2 = (psum + jmax) * (n - 1); if(kei > kei2){ System.out.println(kei); } else{ System.out.println(kei2); } } } }
Main.java:2: error: class Paipu is public, should be declared in a file named Paipu.java public class Paipu{ ^ 1 error
s620295446
p00255
C
#include<cstdio> #include<algorithm> #include<iostream> #include<functional> using namespace std; int main(void) { long long int i,n,paipu,p,joi[65000],honsuu,max,m; scanf("%lld",&n); honsuu=n; paipu=0; for(i=0;i<n;i++){ scanf("%lld",&p); paipu+=p; } for(i=0;i<n-1;i++) scanf("%lld",&joi[i]); sort(joi,joi+n-1,greater<int>()); max=paipu*honsuu; for(i=0;i<n-1;i++){ paipu+=joi[i]; honsuu--; m=paipu*honsuu; if(max<m) max=m; } printf("%lld",max); return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s818026898
p00255
C
#include <stdio.h> int main(void) { __int64 i, k; __int64 n; __int64 p[65000]; __int64 j[64999]; __int64 max; __int64 chain[64999]; __int64 buf; __int64 p_no; __int64 j_max; __int64 bond; while (1){ scanf("%I64d", &n); if (n == 0){ break; } for (i = 0; i < n; i++){ scanf("%I64d", &p[i]); } for (i = 0; i < n - 1; i++){ scanf("%I64d", &j[i]); } /*繋げなかった時の給料*/ buf = 0; for (i = 0; i < n; i++){ buf += p[i]; chain[i] = p[i];/*pをchainにコピー*/ } max = n * buf; /*1本ずつ繋げて給料計算していく*/ /* 1.一番長いパイプをつなげる 2.maxより給料が高いなら1へ 3.maxより低くなったら終了 */ p_no = n; while (p_no > 1){ /*一番長いジョイントを探す*/ j_max = 0; for (i = 1; i < n; i++){ if (j[j_max] < j[i]){ j_max = i; } } /*一番長いパイプをつなげる*/ bond = 0; for (i = 0; i < n - 1; i++){ if (i == j_max){ bond = 1; chain[i] = chain[i] + j[i] + chain[i + 1]; p_no--; i++; } else { chain[i - bond] = p[i]; } } chain[n - 2] = p[i]; /*給料判定*/ buf = 0; for (i = 0; i < p_no; i++){ buf += chain[i]; } if (max <= buf * p_no){ max = buf * p_no; } /*else { break; }*/ } printf("%I64d\n", max); } return (0); } /*音ゲーに囲まれながら…*/
main.c: In function 'main': main.c:6:9: error: unknown type name '__int64'; did you mean '__int64_t'? 6 | __int64 i, k; | ^~~~~~~ | __int64_t main.c:7:9: error: unknown type name '__int64'; did you mean '__int64_t'? 7 | __int64 n; | ^~~~~~~ | __int64_t main.c:8:9: error: unknown type name '__int64'; did you mean '__int64_t'? 8 | __int64 p[65000]; | ^~~~~~~ | __int64_t main.c:9:9: error: unknown type name '__int64'; did you mean '__int64_t'? 9 | __int64 j[64999]; | ^~~~~~~ | __int64_t main.c:10:9: error: unknown type name '__int64'; did you mean '__int64_t'? 10 | __int64 max; | ^~~~~~~ | __int64_t main.c:11:9: error: unknown type name '__int64'; did you mean '__int64_t'? 11 | __int64 chain[64999]; | ^~~~~~~ | __int64_t main.c:12:9: error: unknown type name '__int64'; did you mean '__int64_t'? 12 | __int64 buf; | ^~~~~~~ | __int64_t main.c:13:9: error: unknown type name '__int64'; did you mean '__int64_t'? 13 | __int64 p_no; | ^~~~~~~ | __int64_t main.c:14:9: error: unknown type name '__int64'; did you mean '__int64_t'? 14 | __int64 j_max; | ^~~~~~~ | __int64_t main.c:15:9: error: unknown type name '__int64'; did you mean '__int64_t'? 15 | __int64 bond; | ^~~~~~~ | __int64_t
s859353664
p00255
C
#include <stdio.h> int main(void) { int p[65000]; int j[64999]; int n; __int64 sum; int flag; int max_j; int max_p; __int64 max; int i; while (1){ scanf("%d", &n); if (n == 0){ break; } for (i = 0; i < n; i++){ scanf("%d", &p[i]); } for (i = 0; i < n - 1; i++){ scanf("%d", &j[i]); } /*繋げてないとき*/ max = 0; for (i = 0; i < n; i++){ max += p[i]; } max *= n; /*printf("%I64d\n", max);*/ /*一番高い給料を調べる*/ flag = 0; while (flag < n - 1){ flag++; sum = 0; /*長いジョイントを調べる*/ max_j = j[0]; for (i = flag; i < n - 1; i++){ if (max_j < j[i]){ max_j = j[i]; } } /*ジョイントをくっつける*/ for (i = 0; i < n; i++){ sum += p[i]; } sum += max_j; /*給料計算*/ if (max < sum * (n - flag)){ max = sum * (n - flag); } /*printf("%I64d\n", sum * (n - flag));*/ } printf("%I64d\n", max); } return (0); }
main.c: In function 'main': main.c:8:9: error: unknown type name '__int64'; did you mean '__int64_t'? 8 | __int64 sum; | ^~~~~~~ | __int64_t main.c:12:9: error: unknown type name '__int64'; did you mean '__int64_t'? 12 | __int64 max; | ^~~~~~~ | __int64_t
s996380313
p00255
C
#include <stdio.h> int main(void) { int p[65000]; int j[64999]; int n; __int64 sum; int flag; int max_j; int max_p; __int64 max; int i; while (1){ scanf("%d", &n); if (n == 0){ break; } for (i = 0; i < n; i++){ scanf("%d", &p[i]); } for (i = 0; i < n - 1; i++){ scanf("%d", &j[i]); } /*繋げてないとき*/ max = 0; sum = 0; for (i = 0; i < n; i++){ sum += p[i]; } max = sum * n; /*printf("%lld\n", max);*/ /*一番高い給料を調べる*/ flag = 0; while (flag < n - 1){ flag++; /*長いジョイントを調べる*/ max_j = j[0]; for (i = flag; i < n - 1; i++){ if (max_j < j[i]){ max_j = j[i]; } } /*ジョイントをくっつける*/ /*給料計算*/ if (max < (sum + max_j) * (n - flag)){ max = (sum + max_j) * (n - flag); } /*printf("%lld\n", sum * (n - flag));*/ } printf("%I64d\n", max); } return (0); }
main.c: In function 'main': main.c:8:9: error: unknown type name '__int64'; did you mean '__int64_t'? 8 | __int64 sum; | ^~~~~~~ | __int64_t main.c:12:9: error: unknown type name '__int64'; did you mean '__int64_t'? 12 | __int64 max; | ^~~~~~~ | __int64_t
s316109611
p00255
C
include <stdio.h> void sort(unsigned int *data,unsigned int n){ unsigned int i,flag,tmp; do{ flag = 0; for(i = 0;i < n-1;i++){ if(data[i] > data[i+1]){ tmp = data[i]; data[i] = data[i+1]; data[i+1] = tmp; flag = 1; } } }while(flag); } int main(){ unsigned int n,i,sum,pipe; unsigned int joint[65000]; unsigned int price; while(1){ scanf("%d",&n); if(n == 0){ break; } sum = 0; for(i = 0;i < n;i++){ scanf("%d",&pipe); sum += pipe; } for(i = 0;i < n-1;i++){ scanf("%d",&joint[i]); } sort(joint,n-1); price = sum*n; for(i = 0;i < n-1;i++){ if(price < (sum+joint[i])*(n-1)){ price = (sum+joint[i])*(n-1); } } printf("%u\n",price); } return 0; }
main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include <stdio.h> | ^ main.c: In function 'main': main.c:26:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 26 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | include <stdio.h> main.c:26:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 26 | scanf("%d",&n); | ^~~~~ main.c:26:5: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:41:5: error: implicit declaration of function 'sort' [-Wimplicit-function-declaration] 41 | sort(joint,n-1); | ^~~~ main.c:51:5: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 51 | printf("%u\n",price); | ^~~~~~ main.c:51:5: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:51:5: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:51:5: note: include '<stdio.h>' or provide a declaration of 'printf'
s575204005
p00255
C++
#include <iostream> #include <string> #include <vector> #include <cstring> #include <climits> #include <algorithm> #include <map> using namespace std; typedef unsigned int uint; int main() { sync_with_stdio(false); int n; while (cin >> n, n) { uint num = n, sum = 0, p; for (int i=0; i<n; ++i) { cin >> p; sum += p; } vector<uint> joint; uint j; for (int i=0; i<n-1; ++i) { cin >> j; joint.push_back(j); } sort(joint.begin(), joint.end(), greater<uint>()); uint res = sum * n; for (int i=0; i<n-1; ++i) { sum += joint[i]; num -= 1; if (res < sum * num) { res = sum * num; } } cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:5: error: 'sync_with_stdio' was not declared in this scope 12 | sync_with_stdio(false); | ^~~~~~~~~~~~~~~
s646305100
p00255
C++
#include <iostream> #include <algorithm> using namespace std; int main() { long long n, t, v[65000], sum; while (true) { cin >> n; if (n == 0) { break; } sum = 0; for (int i = 0; i < n; i++) { cin >> t; sum += t; } for (int j = 0; j < n - 1; j++) { cin >> v[j]; sum += v[j]; } sort(v, v + n - 1); int ptr = 0; while(ptr++ < n) { if (ptr * sum < (ptr + 1) * (sum - v[ptr - 1])) { sum -= v[i - 1]; } else { break; } } cout << ptr * sum << endl; } return 0; }
a.cc: In function 'int main()': a.cc:40:42: error: 'i' was not declared in this scope 40 | sum -= v[i - 1]; | ^
s765529155
p00255
C++
#include <algorithm> #include <iostream> #define N 65000 using namespace std; typedef long long ll; int main(){ ll n,p,j[N],a,c; while(1){ cin>>n; if(!n) break; c=0; for(int i=0;i<n;i++) cin>>p,cal+=p; for(int i=0;i<n-1;i++) cin>>j[i],c+=j[i]; sort(j,j+n-1); a=c; for(int i=0;i<n-1;i++) c-=j[i],a=max(ans,c*(i+2)); cout<<a<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:33: error: 'cal' was not declared in this scope 13 | for(int i=0;i<n;i++) cin>>p,cal+=p; | ^~~ a.cc:17:42: error: 'ans' was not declared in this scope; did you mean 'abs'? 17 | for(int i=0;i<n-1;i++) c-=j[i],a=max(ans,c*(i+2)); | ^~~ | abs
s908636495
p00255
C++
#include <stdio.h> int main(void){ int n,p,P,j[1000],J,n,i,bow,o; scanf("%d",&n); while(n!=0){ J=0; p=0; o=2; for(i=1;i<=n;i++){ scanf("%d",&P); p+=P; } for(i=1;i<=n-1;i++){ scanf("%d",&j[i]); J+=j[i]; } bow=p+J; for(i=n-1;i>0;i--){ J-=j[i]; if(bow<(J+p)*o){ bow=(J+p)*o; } o++; } printf("%d\n",bow); scanf("%d",&n); } return 0; }
a.cc: In function 'int main()': a.cc:3:29: error: redeclaration of 'int n' 3 | int n,p,P,j[1000],J,n,i,bow,o; | ^ a.cc:3:13: note: 'int n' previously declared here 3 | int n,p,P,j[1000],J,n,i,bow,o; | ^
s445291484
p00255
C++
// 2012 toi5 start 13:15 #include<map> #include<list> #include<queue> #include<stack> #include<vector> #include<conio.h> #include<string.h> #include<iostream> #include<functional> #include<algorithm> using namespace std; int main(){ long long n, i, t, sump = 0, sumj = 0, maxv = 0, v; while (cin >> n, n){ long long p[1000], j[1000]; for (int i = 0; i < n; i++){ cin >> p[i]; sump += p[i]; } for (int i = 0; i < n - 1; i++){ cin >> j[i]; } sort(j, j + n - 1, greater<int>()); for (i = 0, t = n; t >= 1; t--, i++){//??????????????¬??°????????§??????????????¬??°??? maxv = t*(sump + sumj); sumj += j[i]; v = max(maxv, v); } cout << v << endl; sump = 0, sumj = 0, maxv = 0; } return 0; }
a.cc:7:9: fatal error: conio.h: No such file or directory 7 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s735128099
p00255
C++
#include<map> #include<list> #include<queue> #include<stack> #include<vector> #include<conio.h> #include<string.h> #include<iostream> #include<functional> #include<algorithm> using namespace std; int main(){ long long n, i, t, sump = 0, sumj = 0, maxv = 0, v; while (cin >> n, n){ long long p[1001], j[1001]; for (i = 0; i < n; i++){ cin >> p[i]; sump += p[i]; } for (i = 0; i < n - 1; i++){ cin >> j[i]; } sort(j, j + n - 1, greater<int>()); for (i = 0, t = n; t >= 1; t--, i++){//??????????????¬??°????????§??????????????¬??°??? maxv = t*(sump + sumj); sumj += j[i]; v = max(maxv, v); } cout << v << endl; sump = 0, sumj = 0, maxv = 0; } return 0; }
a.cc:6:9: fatal error: conio.h: No such file or directory 6 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s672914324
p00255
C++
// 2012 toi5 start 13:15 #include<map> #include<list> #include<queue> #include<stack> #include<vector> #include<conio.h> #include<string.h> #include<iostream> #include<functional> #include<algorithm> using namespace std; int main(){ long long n, i, t, sump = 0, sumj = 0, maxv = 0, v; while (cin >> n, n){ long long p[1001], j[1001]; for (i = 0; i < n; i++){ cin >> p[i]; sump += p[i]; } for (i = 0; i < n - 1; i++){ cin >> j[i]; } sort(j, j + n , greater<int>()); for (i = 0, t = n; t >= n/2; t--, i++){//??????????????¬??°????????§??????????????¬??°??? maxv = t*(sump + sumj); sumj += j[i]; v = max(maxv, v); } cout << v << endl; sump = 0, sumj = 0, maxv = 0; } return 0; }
a.cc:7:9: fatal error: conio.h: No such file or directory 7 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s878689208
p00255
C++
// 2012 toi5 start 13:15 #include<map> #include<list> #include<queue> #include<stack> #include<vector> //#include<conio.h> #include<string.h> #include<iostream> #include<functional> #include<algorithm> using namespace std; int main(){ long long n, i, t, sump = 0, sumj = 0, maxv = 0, v = 0; while (cin >> n, n){ long long p[1001], j[1001]; for (i = 0; i < n; i++){ cin >> p[i]; sump += p[i]; } for (i = 0; i < n - 1; i++){ cin >> j[i]; } sort(j, j + n , greater<int>()); for (i = 0, t = n; t >=1 ; t--, i++){//??????????????¬??°????????§??????????????¬??°??? maxv = max(t*(sump + sumj), t*(sump + sumj + j[i])); sumj += j[i]; } cout << maxv << endl; sump = 0, sumj = 0, maxv = 0; } return 0; } a /*#include <iostream> using namespace std; template <typename T> void prt(T outData) { std::cout << outData << endl; } template <typename T> void prtar(T outDataArray[], size_t ArraySize, bool instFlg = false) { for (unsigned int i = 0; i < ArraySize / sizeof(outDataArray[0]); i++) { if (instFlg) { std::cout << outDataArray[i] << endl; } else { std::cout << "ARRAY[" << i << "] : " << outDataArray[i] << endl; } } } int main() { int A[10]; for (int i = 0; i < 10; i++) cin >> A[i]; prtar(A, sizeof(A)); return 0; }*/
a.cc:35:1: error: 'a' does not name a type 35 | a | ^
s372205742
p00255
C++
#include<map> #include<list> #include<queue> #include<stack> #include<vector> //#include<conio.h> #include<string.h> #include<iostream> #include<functional> #include<algorithm> using namespace std; typedef long long ll int main(){ ll n, i, t, sump = 0, sumj = 0, maxv = 0, v = 0; while (cin >> n, n){ int p[1001], j[1001]; for (i = 0; i < n; i++){ cin >> p[i]; sump += p[i]; } for (i = 0; i < n - 1; i++){ cin >> j[i]; } maxv = sump*n; sort(j, j + n , greater<int>()); for (i = 0, t = n-1; t >=1 ; t--, i++){//??????????????¬??°????????§??????????????¬??°??? v += j[i]; maxv = max(t*(sump + v), maxv); //cout << t*(sump + v) << " " << maxv << endl; } cout << maxv << endl; sump = 0, sumj = 0, maxv = 0, v = 0; } return 0; }
a.cc:13:1: error: expected initializer before 'int' 13 | int main(){ | ^~~
s957334762
p00255
C++
/* // PCK 2012 Q6 --- Mayan Crucial Prediction #include <iostream> #include <cstring> #include <cstdlib> #include "MDebug.h" using namespace std; const static int Manth_Day[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static const int MAX_B = 13; static const int MAX_KA = 20; static const int MAX_T = 20; static const int MAX_W = 18; static const int MAX_KI = 20; static const int MAX_DAY = 365; int main() { int CalLength, DivCnt = 0, WordCnt = 0; int B, KA, T, W, KI; int Y, M, D; char Calendar[15]; char Calendar_Indiv[5][13]; bool MayanFlg; while( cin >> Calendar, Calendar[0] != '#' ) { CalLength = strlen( Calendar ); for( int i = 0; i < CalLength; i++ ) { if( Calendar[i] != '.' ) { Calendar_Indiv[DivCnt][WordCnt] = Calendar[i]; } else { DivCnt++; WordCnt = 0; continue; } WordCnt++; } if( strlen( Calendar_Indiv[0] ) >= 4 ) { Y = atoi( Calendar_Indiv[0] ); M = atoi( Calendar_Indiv[1] ); D = atoi( Calendar_Indiv[2] ); MayanFlg = false; } else { B = atoi( Calendar_Indiv[0] ); KA = atoi( Calendar_Indiv[1] ); T = atoi( Calendar_Indiv[2] ); W = atoi( Calendar_Indiv[3] ); KI = atoi( Calendar_Indiv[4] ); MayanFlg = true; } if( MayanFlg ) { int sumKin = 0, tempKin; bool empty = false; Y = 2012; M = 12; D = 21; sumKin += ( ( B * MAX_KA * MAX_T * MAX_W * MAX_KI ) + ( KA * MAX_T * MAX_W * MAX_KI ) + ( T * MAX_W * MAX_KI ) + ( W * MAX_KI ) + KI ); tempKin = sumKin; while( true ) { if( sumKin == 0 ) { empty = true; break; } else if( D == 32 ) { Y++; M = 1; D = 1; break; } D++; sumKin--; } while( true ) { if( !( Y % 4 ) && ( ( Y % 100 ) || !( Y % 400 ) ) ) { if( sumKin - ( MAX_DAY + 1 ) < 0 ) break; sumKin -= ( MAX_DAY + 1 ); Y++; } else if( sumKin - MAX_DAY < 0 ) break; else { sumKin -= MAX_DAY; Y++; } } while( true ) { if( !( Y % 4 ) && ( ( Y % 100 ) || !( Y % 400 ) ) ) { for( int i = 0; i < 12; i++ ) { if( sumKin - ( Manth_Day[i] == 28 ? Manth_Day[i] + 1 : Manth_Day[i] ) < 0 ) break; sumKin -= ( Manth_Day[i] == 28 ? Manth_Day[i] + 1 : Manth_Day[i] ); M++; } } else { for( int i = 0; i < 12; i++ ) { if( sumKin - Manth_Day[i] < 0 ) break; sumKin -= Manth_Day[i]; M++; } } } D += sumKin; } cout << Y << ":" << M << ":" << D << endl; } return 0; } */ #include<iostream> #include<algorithm> using namespace std; #define REP(i,a) for( int i = 0; i < a; i++ ) void AAA(int,int,int); int pipe[65001]; int joi[65002], kanemax = -1; int nagasa = 0; int sosu = 0; int main() { int n; cin >> n; while( n != 0 ){ REP( i, n ){ cin >> pipe[i]; nagasa += pipe[i]; } REP( i, n - 1 ){ cin >> joi[i]; } sosu = n; AAA( sosu, nagasa, 0 ); cout << kanemax << endl; nagasa = 0; kanemax = 0; cin >> n; } return 0; } void AAA( int a, int b, int c ) { if( c == n ){ if( kanemax < b * a ) kanemax = b * a; } else{ AAA( a - 1, b + joi[c], c + 1 ); AAA( a, b, c + 1 ); } }
a.cc: In function 'void AAA(int, int, int)': a.cc:188:18: error: 'n' was not declared in this scope 188 | if( c == n ){ | ^
s010188149
p00255
C++
#include <iostream> #include <algorithm> using namespace std; #define REP(i,a) for( int i = 0; i < a; i++ ) void AAA(int,int,int); int pipe[65001]; int joi[65001] int kanemax = -1; int nagasa = 0; int sosu = 0; int n; int main() { cin >> n; while( n != 0 ){ for( int i = 0; i < n; i++ ) { cin >> pipe[i]; nagasa += pipe[i]; } for( int i = 0; i < n - 1; i++ ) { cin >> joi[i]; } sosu = n; AAA( sosu, nagasa, 0 ); cout << kanemax << endl; nagasa = 0; kanemax = 0; cin >> n; } return 0; } void AAA( int a, int b, int c ) { if( c == n ){ if( kanemax < b * a ) kanemax = b * a; } else{ AAA( a - 1, b + joi[c], c + 1 ); AAA( a, b, c + 1 ); } }
a.cc:11:1: error: expected initializer before 'int' 11 | int kanemax = -1; | ^~~ a.cc: In function 'int main()': a.cc:26:32: error: 'joi' was not declared in this scope 26 | cin >> joi[i]; | ^~~ a.cc:31:25: error: 'kanemax' was not declared in this scope 31 | cout << kanemax << endl; | ^~~~~~~ a.cc: In function 'void AAA(int, int, int)': a.cc:44:21: error: 'kanemax' was not declared in this scope 44 | if( kanemax < b * a ) kanemax = b * a; | ^~~~~~~ a.cc:48:33: error: 'joi' was not declared in this scope 48 | AAA( a - 1, b + joi[c], c + 1 ); | ^~~
s443189270
p00255
C++
#include <iostream> #include <algorithm> #include <cstring> using namespace std; long long kanemax = -1; long long nagasa = 0; long long sosu = 0; int n; void AAA( long long a, long long b, long long c, long long joi[] ) { if( c == n ){ if( kanemax < b * a ) kanemax = b * a; } else{ AAA( a - 1, b + joi[c], c + 1 ); AAA( a, b, c + 1 ); } } int main() { long long pipe[65001], joi[65001]; cin >> n; while( n != 0 ){ memset( pipe, 0, sizeof( pipe ) ); memset( joi, 0, sizeof( joi ) ); for( int i = 0; i < n; i++ ) { cin >> pipe[i]; nagasa += pipe[i]; } for( int i = 0; i < n - 1; i++ ) { cin >> joi[i]; } sosu = n; AAA( sosu, nagasa, 0, joi ); cout << kanemax << endl; nagasa = 0; kanemax = 0; cin >> n; } return 0; }
a.cc: In function 'void AAA(long long int, long long int, long long int, long long int*)': a.cc:18:20: error: too few arguments to function 'void AAA(long long int, long long int, long long int, long long int*)' 18 | AAA( a - 1, b + joi[c], c + 1 ); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:11:6: note: declared here 11 | void AAA( long long a, long long b, long long c, long long joi[] ) | ^~~ a.cc:19:20: error: too few arguments to function 'void AAA(long long int, long long int, long long int, long long int*)' 19 | AAA( a, b, c + 1 ); | ~~~^~~~~~~~~~~~~~~ a.cc:11:6: note: declared here 11 | void AAA( long long a, long long b, long long c, long long joi[] ) | ^~~
s836146975
p00255
C++
#include<iostream> #include<algorithm> using namespace std; void AAA(int,int,int, int*); int kanemax=-1; int nagasa=0; int sosu=0,n; #define REP(i,a) for(int i=0;i<a;i++) int main() { int pipe[65001], joi[65002]; cin>>n; while(n!=0){ REP(i,n){ cin>>pipe[i]; nagasa+=pipe[i]; } REP(i,n-1){ cin>>joi[i]; } sosu=n; AAA(sosu,nagasa,0); cout<<kanemax<<endl; nagasa=0; kanemax=0; cin>>n; } return 0; } void AAA(int a,int b,int c, int joi[]) { if(c==n){ if(kanemax<b*a) kanemax=b*a; } else{ AAA(a-1,b+joi[c],c+1); AAA(a,b,c+1); } }
a.cc: In function 'int main()': a.cc:28:20: error: too few arguments to function 'void AAA(int, int, int, int*)' 28 | AAA(sosu,nagasa,0); | ~~~^~~~~~~~~~~~~~~ a.cc:5:6: note: declared here 5 | void AAA(int,int,int, int*); | ^~~ a.cc: In function 'void AAA(int, int, int, int*)': a.cc:44:20: error: too few arguments to function 'void AAA(int, int, int, int*)' 44 | AAA(a-1,b+joi[c],c+1); | ~~~^~~~~~~~~~~~~~~~~~ a.cc:37:6: note: declared here 37 | void AAA(int a,int b,int c, int joi[]) | ^~~ a.cc:45:20: error: too few arguments to function 'void AAA(int, int, int, int*)' 45 | AAA(a,b,c+1); | ~~~^~~~~~~~~ a.cc:37:6: note: declared here 37 | void AAA(int a,int b,int c, int joi[]) | ^~~
s607963932
p00255
C++
#include<iostream> #include<algorithm> using namespace std; void solve(int a,int b,int c, int joi[]); int kanemax=-1; int nagasa=0; int sosu=0,n; #define REP(i,a) for(int i=0;i<a;i++) int main() { int pipe[65001], joi[65002]; cin>>n; while(n!=0){ REP(i,n){ cin>>pipe[i]; nagasa+=pipe[i]; } REP(i,n-1){ cin>>joi[i]; } sosu=n; solve(sosu,nagasa,0); cout<<kanemax<<endl; nagasa=0; kanemax=0; cin>>n; } return 0; } void solve(int a,int b,int c, int joi[]) { if(c==n){ if(kanemax<b*a) kanemax=b*a; } else{ solve(a-1,b+joi[c],c+1, joi[]); solve(a,b,c+1, joi[]); } }
a.cc: In function 'int main()': a.cc:28:22: error: too few arguments to function 'void solve(int, int, int, int*)' 28 | solve(sosu,nagasa,0); | ~~~~~^~~~~~~~~~~~~~~ a.cc:5:6: note: declared here 5 | void solve(int a,int b,int c, int joi[]); | ^~~~~ a.cc: In function 'void solve(int, int, int, int*)': a.cc:44:45: error: expected primary-expression before ']' token 44 | solve(a-1,b+joi[c],c+1, joi[]); | ^ a.cc:45:36: error: expected primary-expression before ']' token 45 | solve(a,b,c+1, joi[]); | ^
s635345640
p00255
C++
3 1 1 1 3 3
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s608745171
p00255
C++
#include<stdio.h> int main(void) { long long int n,p,j[70000],sum,x,i,k,max; while(1){ scanf("%lld",&n); if(n==0) break; sum=0; for(i=0;i<n;i++){ scanf("%lld",&p); sum+=p; } for(i=0;i<n-1;i++){ scanf("%lld",&j[i]); // printf("i=%d\n",i); } qsort(j[0],j[n-1]); max=0; for(i=0;i<n;i++){ if(max<(n-i)*sum) max=(n-i)*sum; else break; sum+=j[i]; } printf("%d\n",max); } return 0; }
a.cc: In function 'int main()': a.cc:17:17: error: 'qsort' was not declared in this scope 17 | qsort(j[0],j[n-1]); | ^~~~~
s744247120
p00255
C++
#include<stdio.h> int main(void) { long long int n,p,j[70000],sum,x,i,k,max; while(1){ scanf("%lld",&n); if(n==0) break; sum=0; for(i=0;i<n;i++){ scanf("%lld",&p); sum+=p; } for(i=0;i<n-1;i++){ scanf("%lld",&j[i]); // printf("i=%d\n",i); } qsort(j[0],j[n-1]); max=0; for(i=0;i<n;i++){ if(max<(n-i)*sum) max=(n-i)*sum; else break; sum+=j[i]; } printf("%d\n",max); } return 0; }
a.cc: In function 'int main()': a.cc:17:17: error: 'qsort' was not declared in this scope 17 | qsort(j[0],j[n-1]); | ^~~~~
s763933938
p00255
C++
#include<bits/stdc++.h> using namespace std; lnog long int p[100000],j[100000]; int main(void) { long long int n,sum,sum1,max,cnt,i; while(1){ scanf("%lld",&n); if(n==0) break; sum=0; for(i=0;i<n;i++){ scanf("%lld",&p[i]); sum+=p[i]; } cnt=n; max=sum*cnt; for(i=0;i<n-1;i++){ scanf("%lld",&j[i]); j[i]*=-1; } sort(j,j+n); for(i=0;i<n-1;i++) j[i]*=-1; for(i=0;i<n-1;i++){ cnt--; sum+=j[i]; sum1=sum*cnt; if(max<sum1) max=sum1; // printf("%d\n",sum1); } printf("%lld\n",max); } return 0; }
a.cc:3:1: error: 'lnog' does not name a type; did you mean 'long'? 3 | lnog long int p[100000],j[100000]; | ^~~~ | long a.cc: In function 'int main()': a.cc:12:39: error: 'p' was not declared in this scope 12 | scanf("%lld",&p[i]); | ^ a.cc:17:39: error: 'j' was not declared in this scope 17 | scanf("%lld",&j[i]); | ^ a.cc:20:22: error: 'j' was not declared in this scope 20 | sort(j,j+n); | ^
s844257459
p00255
C++
#include <iostream> using namespace std; typedef long long ll; ll n; ll a[70000], b[70000]; int main(){ while(cin >> n, n){ ll sumA = 0; ll sumB = 0; for(int i = 0; i < n; i++){ cin >> a[i]; sumA += a[i]; } for(int i = 0; i < n - 1; i++){ cin >> b[i]; sumB += b[i]; } sort(b, b + (n - 1)); ll ans = 0; for(int i = 1; i <= n; i++){ ans = max(ans, i * (sumA + sumB)); sumB -= b[i - 1]; } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:22:5: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(b, b + (n - 1)); | ^~~~ | short
s378491077
p00255
C++
#include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; long long int x = 0; long long int y = 0; long long int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%lld\n",ans); } return 0; } #include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; long long int x = 0; long long int y = 0; long long int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%lld\n",ans); } return 0; }
a.cc:48:5: error: redefinition of 'int main()' 48 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~
s966922960
p00255
C++
#include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; long long int x = 0; long long int y = 0; long long int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%lld\n",ans); } return 0; } #include<cstdio> #include<algorithm> using namespace std; int main(){ int n; while(scanf("%d",&n),n){ int p[10000]={0}; long long int x = 0; long long int y = 0; long long int ans = 0; for(int i = 0; i < n; i++){ scanf("%d",&p[i]); y += p[i]; } sort(p,p+n); int j[10000]={0}; for(int i = 0; i < n-1; i++){ scanf("%d",&j[i]); x += j[i]; } sort(j,j+n-1); x += y; int cnt = 1; ans = x; while(1){ cnt++; if(cnt == n)break; for(int i = 0; i < n-1; i++){ if(p[i] != -1){ p[i] = -1; x -= j[i]; break; } } if(ans > x*cnt){ break; } ans = x*cnt; } ans = max(ans,y*n); printf("%d\n",ans); } return 0; }
a.cc:48:5: error: redefinition of 'int main()' 48 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~