結果
問題 | No.358 も~っと!門松列 |
ユーザー |
![]() |
提出日時 | 2017-07-18 20:08:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 36,684 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 10:58:17 |
合計ジャッジ時間 | 1,210 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 4 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d%d%d",&A[0],&A[1],&A[2]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<algorithm> using namespace std; main(){ int A[3]; scanf("%d%d%d",&A[0],&A[1],&A[2]); if(A[0]==A[1] || A[1]==A[2] || A[2]==A[0]){ printf("0\n"); return 0; } if(A[1]==1 && A[0]!=1 && A[2]!=1){ printf("INF\n"); return 0; } if((A[1] > A[0] && A[1] > A[2])|| A[1] < A[0] && A[1] < A[2]){ printf("INF\n"); return 0; } int count = 0; for(int i = 2;i <= 1001;i++){ int B[3]; for(int j = 0;j < 3;j++){ B[j] = A[j] % i; } sort(B,B+3); if(B[0]!=B[1] && B[1]!=B[2] && B[2]!=B[0]) if(B[0]==A[1]%i || B[2]==A[1]%i){ count++; } } printf("%d\n",count); }