結果

問題 No.677 10^Nの約数
ユーザー butsurizukibutsurizuki
提出日時 2018-06-08 15:52:25
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 29,160 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 23:20:31
合計ジャッジ時間 1,015 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:4:11: 警告: conflicting types for built-in function ‘pow’; expected ‘double(double,  double)’ [-Wbuiltin-declaration-mismatch]
    4 | long long pow(long long a,long long n){
      |           ^~~
main.c:3:1: 備考: ‘pow’ is declared in header ‘<math.h>’
    2 | #include<stdlib.h>
  +++ |+#include <math.h>
    3 | 
main.c: 関数 ‘main’ 内:
main.c:29:35: 警告: 互換性のないポインタ型から 4 番目の ‘qsort’ の引数に渡しています [-Wincompatible-pointer-types]
   29 |     qsort(arr,q,sizeof(long long),sortfnc);
      |                                   ^~~~~~~
      |                                   |
      |                                   long long int (*)(const void *, const void *)
次のファイルから読み込み:  main.c:2:
/usr/include/stdlib.h:828:34: 備考: expected ‘__compar_fn_t’ {aka ‘int (*)(const void *, const void *)’} but argument is of type ‘long long int (*)(const void *, const void *)’
  828 |                    __compar_fn_t __compar) __nonnull ((1, 4));
      |                    ~~~~~~~~~~~~~~^~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

long long pow(long long a,long long n){
    long long r=1,i;
    for(i=0;i<n;i++){r*=a;}
    return r;
}

long long sortfnc(const void *a,const void *b) {
  if(*(long long *)a < *(long long *)b){
    return -1;
  }
  else if(*(long long *)a == *(long long *)b){
    return 0;
  }
  return 1;
}

int main(){
    long long q,i,j,n,arr[512];
    scanf("%lld",&n);
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            arr[(n+1)*i+j]=pow(2,i)*pow(5,j);
        }
    }
    q=(n+1)*(n+1);
    qsort(arr,q,sizeof(long long),sortfnc);
    for(i=0;i<q;i++){printf("%lld\n",arr[i]);}
    return 0;
}
0