結果
| 問題 |
No.152 貯金箱の消失
|
| コンテスト | |
| ユーザー |
TLwiegehtt
|
| 提出日時 | 2015-07-14 08:29:03 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 5,000 ms |
| コード長 | 528 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 21,120 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 07:06:16 |
| 合計ジャッジ時間 | 906 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:19:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d", &L);
| ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int gcd( int a, int b){
if(b == 0){
return a;
}
if(a > b){
return gcd(b,a%b);
}else{
return gcd(a,b%a);
}
}
int main(void){
int cnt=0;
int L,m,n;
scanf("%d", &L);
L = L / 4;
for(n=1;n<3000;n++){
for(m=n+1;m<3000;m++){
int a,b,c;
int g = gcd(n,m);
if((m-n)%2==0){continue;}
if( g != 1){continue;}
a = (m*m-n*n);
b = (2*m*n);
c = (m*m+n*n);
if(a+b+c <= L){
cnt = (cnt+1) % 1000003;
}else{
break;
}
}
}
printf("%d\n", cnt);
return 0;
}
TLwiegehtt