結果

問題 No.152 貯金箱の消失
ユーザー akakimidoriakakimidori
提出日時 2016-12-09 00:37:21
言語 C90
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 414 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 24,192 KB
最終ジャッジ日時 2024-05-06 09:49:23
合計ジャッジ時間 789 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function ‘main’:
main.c:16:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d",&L);
      |   ^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccT75Ygk.o: in function `main':
main.c:(.text.startup+0x155): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status

ソースコード

diff #

#include<stdio.h>
#include<math.h>

int gcd(int m,int n){
  int r=m%n;
  while(r>0){
    m=n;
    n=r;
    r=m%n;
  }
  return n;
}

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

  L=L/4;
  int m,n;
  int count=0;
  for(m=2;m<=(-1.0+sqrt(1+2*L))/2;m++){
    for(n=1+(m&0x01);n<m && n<=L/(2*m)-m;n+=2){
      if(gcd(m,n)==1){
        count=(count+1)%1000003;
      }
    }
  }

  printf("%d\n",count);

  return 0;
}
0