結果

問題 No.219 巨大数の概算
ユーザー S_F__
提出日時 2015-09-19 07:22:47
言語 C90
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 474 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 15,168 KB
最終ジャッジ日時 2024-07-19 07:52:44
合計ジャッジ時間 6,242 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other TLE * 1 -- * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:5: warning: conflicting types for built-in function ‘log10’; expected ‘double(double)’ [-Wbuiltin-declaration-mismatch]
    3 | int log10(long n){
      |     ^~~~~
main.c:2:1: note: ‘log10’ is declared in header ‘<math.h>’
    1 | #include <stdio.h>
  +++ |+#include <math.h>
    2 | 
main.c:9:8: warning: conflicting types for built-in function ‘pow10’; expected ‘double(double)’ [-Wbuiltin-declaration-mismatch]
    9 | double pow10(long n){
      |        ^~~~~
main.c: In function ‘main’:
main.c:26:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long int’ [-Wformat=]
   26 |     printf("%d %d %d", X, Y, Z);
      |                   ~^         ~
      |                    |         |
      |                    int       long int
      |                   %ld
main.c:19:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |   scanf("%i", &N);
      |   ^~~~~~~~~~~~~~~
main.c:21:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |     scanf("%ld %ld", &A, &B);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int log10(long n){
  int result;
  for(result=0;n>=10;result++)n/=10;
  return result;
}

double pow10(long n){
  double result = 1.0;
  for(;n--;)result *= 10;
  return result;
}

int main(void){
  int I, N, X, Y;
  double S;
  long A, B, Z;
  scanf("%i", &N);
  for(I=0;I<N;I++){
    scanf("%ld %ld", &A, &B);
    Z = log10(A) * B;
    S = (double)A / pow10(Z);
    X = (int)S;
    Y = (int)(S*10)%10;
    printf("%d %d %d", X, Y, Z);
  }
  return 0;
}
0