結果

問題 No.25 有限小数
コンテスト
ユーザー testestest
提出日時 2015-08-13 04:10:33
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 240 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 123 ms
コンパイル使用メモリ 29,124 KB
最終ジャッジ日時 2026-02-23 19:16:44
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:3:1: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
    3 | scanf("%ld%ld",&a,&b);
      | ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | int main(){
main.c:4:34: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
    4 | if(a%b<1){for(a/=b;a%10<1;a/=10);printf("%d",a%10);return 0;}
      |                                  ^~~~~~
main.c:4:34: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:4:43: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
    4 | if(a%b<1){for(a/=b;a%10<1;a/=10);printf("%d",a%10);return 0;}
      |                                          ~^  ~~~~
      |                                           |   |
      |                                           int long int
      |                                          %ld
main.c:7:52: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
    7 | if(b%2<1)puts("5");else{for(a%=10;b&&b-1;a*=2)b/=5;printf("%d",b?a%10:-1);}
      |                                                    ^~~~~~
main.c:7:52: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:7:61: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long int’ [-Wformat=]
    7 | if(b%2<1)puts("5");else{for(a%=10;b&&b-1;a*=2)b/=5;printf("%d",b?a%10:-1);}
      |                                                            ~^  ~~~~~~~~~
      |                                                             |        |
      |                                                             int      long int
      |                                                            %ld

ソースコード

diff #
raw source code

int main(){
long a,b,p,q,t;
scanf("%ld%ld",&a,&b);
if(a%b<1){for(a/=b;a%10<1;a/=10);printf("%d",a%10);return 0;}
for(p=a,q=b;q;q=t)t=p%q,p=q;
a/=p;b/=p;
if(b%2<1)puts("5");else{for(a%=10;b&&b-1;a*=2)b/=5;printf("%d",b?a%10:-1);}
return 0;
}
0