結果
| 問題 | 
                            No.8009 異なる数字の最大の範囲(勉強会用)
                             | 
                    
| ユーザー | 
                             issekiamp
                         | 
                    
| 提出日時 | 2015-02-28 17:36:44 | 
| 言語 | C90  (gcc 12.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 564 bytes | 
| コンパイル時間 | 964 ms | 
| コンパイル使用メモリ | 21,248 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-12 22:27:04 | 
| 合計ジャッジ時間 | 2,323 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 WA * 13 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:16:20: warning: implicit declaration of function ‘calloc’ [-Wimplicit-function-declaration]
   16 |         b = (int *)calloc(a, sizeof(int));
      |                    ^~~~~~
main.c:3:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
    2 | #include <string.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:16:20: warning: incompatible implicit declaration of built-in function ‘calloc’ [-Wbuiltin-declaration-mismatch]
   16 |         b = (int *)calloc(a, sizeof(int));
      |                    ^~~~~~
main.c:16:20: note: include ‘<stdlib.h>’ or provide a declaration of ‘calloc’
main.c:13:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d\r\n", &a);
      |         ^~~~~~~~~~~~~~~~~~~
main.c:14:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         fgets(data, sizeof(data), stdin);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
#include <string.h>
int main(void) {
	// your code goes here
	int a;
	int *b;
	char data[100000];
	char *point;
	int count = 0;
	int i,j;
	
	scanf("%d\r\n", &a);
	fgets(data, sizeof(data), stdin);
	b = (int *)calloc(a, sizeof(int));
	point = strtok(data, " ");
	for (i=0; i<a; i++)
	{
		sscanf(point, "%d", b+i);
		for (j=0; j<i; j++)
		{
			if (*(b+i) == *(b+j))
			{
				break;
			}
		}
		
		if (j == i)
		{
			count++;
		}
		
		point = strtok(NULL, " ");
		if (point == NULL)
		{
			break;
		}
	}
	
	printf("%d\r", count);
	
	return 0;
}
            
            
            
        
            
issekiamp