結果

問題 No.677 10^Nの約数
ユーザー michonz4michonz4
提出日時 2019-12-27 17:00:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 32,768 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 03:55:44
合計ジャッジ時間 1,270 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
typedef long long ll;

int compareUp(const void *a, const void *b) {
  ll *A = (ll *)a;
  ll *B = (ll *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int main() {
  int n;
  scanf("%d", &n);

  int size=(n+1)*(n+1), i, j, k=0;
  ll two[n+1], five[n+1], arr[size];
  
  for (i=0; i<n+1; i++) {
    two[i]=(ll)pow(2, i);
  }
  for (i=0; i<n+1; i++) {
    five[i]=(ll)pow(5, i);
  }

  for (i=0; i<n+1; i++) {
    for (j=0; j<n+1; j++) {
      arr[k++]=two[i]*five[j];
    }
  }

  qsort(arr, size, sizeof(ll), compareUp);
  
  for (int i=0; i<size; i++) {
    printf("%lld\n", arr[i]);
  }
  return 0;
}
0