Language: C++

int n,c[NAX],T[NAX+1];
int greedy(int);
void douteki(int);

int main(){
  int i,g,j,k,flag=0;

  k=1;
  while(1){
    flag=0;
    cin >> n;
    if(n == 0 )break;


    for(i=0;i<n;i++){
      cin >> c[i];
      if(i == 0 && c[i] != 1)flag=1;
    }
    if(n == 1 && c[i-1] == 1){
      cout << "Case #" << k << ": OK" << endl;
      k++;
      continue;
    }

    if(flag == 1){
      cout << "Case #" << k << ": Cannot pay some amount" << endl;
      k++;
      continue;
    }
    else{
      //     for(j=1;j<=100;j++){    
      //    douteki(n);                                                             
      ///   cout << "greedy(" << j << ") =" << greedy(j) << endl;                       
      //   cout << "douteki("<< j << ")="<< T[j] << endl;
      // 	}
   
      
      douteki(n); 
      for(j=1;j<=100000;j++){
	if(greedy(j) > T[j]){
	  flag=3;
	  break;
	}
      } 


    }                                                                      
    /* 
     for(i=1;i<n;i++){
        if(c[i]%c[i-1] != 0)flag = 2;
      }
*/
      if(flag == 0){
        cout << "Case #" << k << ": OK" << endl;
   k++;
      }else{
        cout << "Case #" << k << ": Cannot use greedy algorithm" << endl;
        k++;
        }


    }


}




int greedy(int a){
  int ans=0;
  for(int i = n-1;i>=0;i-- ){
    if(a >= c[i]){
      ans += a/c[i];
   a = a%c[i];
    }
  }
  return ans;

}


void douteki(int re){
  for(int j = 0; j <= NAX ; j++)T[j]=10000;
  T[0] = 0;
 for(int i = 0; i < re ; i++){
    for(int j=c[i];j<=NAX;j++){
      T[j]= min(T[j],T[j-c[i]]+1);
    }
 }

}

Compiler output:
a.cc:1:9: error: 'NAX' was not declared in this scope
    1 | int n,c[NAX],T[NAX+1];
      |         ^~~
a.cc:1:16: error: 'NAX' was not declared in this scope
    1 | int n,c[NAX],T[NAX+1];
      |                ^~~
a.cc: In function 'int main()':
a.cc:11:5: error: 'cin' was not declared in this scope
   11 |     cin >> n;
      |     ^~~
a.cc:16:14: error: 'c' was not declared in this scope
   16 |       cin >> c[i];
      |              ^
a.cc:19:18: error: 'c' was not declared in this scope
   19 |     if(n == 1 && c[i-1] == 1){
      |                  ^
a.cc:20:7: error: 'cout' was not declared in this scope
   20 |       cout << "Case #" << k << ": OK" << endl;
      |       ^~~~
a.cc:20:42: error: 'endl' was not declared in this scope
   20 |       cout << "Case #" << k << ": OK" << endl;
      |                                          ^~~~
a.cc:26:7: error: 'cout' was not declared in this scope
   26 |       cout << "Case #" << k << ": Cannot pay some amount" << endl;
      |       ^~~~
a.cc:26:62: error: 'endl' was not declared in this scope
   26 |       cout << "Case #" << k << ": Cannot pay some amount" << endl;
      |                                                              ^~~~
a.cc:40:24: error: 'T' was not declared in this scope
   40 |         if(greedy(j) > T[j]){
      |                        ^
a.cc:54:9: error: 'cout' was not declared in this scope
   54 |         cout << "Case #" << k << ": OK" << endl;
      |         ^~~~
a.cc:54:44: error: 'endl' was not declared in this scope
   54 |         cout << "Case #" << k << ": OK" << endl;
      |                                            ^~~~
a.cc:57:9: error: 'cout' was not declared in this scope
   57 |         cout << "Case #" << k << ": Cannot use greedy algorithm" << endl;
      |         ^~~~
a.cc:57:69: error: 'endl' was not declared in this scope
   57 |         cout << "Case #" << k << ": Cannot use greedy algorithm" << endl;
      |                                                                     ^~~~
a.cc: In function 'int greedy(int)':
a.cc:73:13: error: 'c' was not declared in this scope
   73 |     if(a >= c[i]){
      |             ^
a.cc: In function 'void douteki(int)':
a.cc:84:23: error: 'NAX' was not declared in this scope
   84 |   for(int j = 0; j <= NAX ; j++)T[j]=10000;
      |                       ^~~
a.cc:84:33: error: 'T' was not declared in this scope
   84 |   for(int j = 0; j <= NAX ; j++)T[j]=10000;
      |                                 ^
a.cc:85:3: error: 'T' was not declared in this scope
   85 |   T[0] = 0;
      |   ^
a.cc:87:15: error: 'c' was not declared in this scope
   87 |     for(int j=c[i];j<=NAX;j++){
      |               ^
a.cc:87:23: error: 'NAX' was not declared in this scope
   87 |     for(int j=c[i];j<=NAX;j++){
      |                       ^~~
a.cc:88:13: error: 'min' was not declared in this scope; did you mean 'main'?
   88 |       T[j]= min(T[j],T[j-c[i]]+1);
      |             ^~~
      |             main