結果
問題 | No.112 ややこしい鶴亀算 |
ユーザー |
![]() |
提出日時 | 2025-03-06 11:40:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 469 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 27,008 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-06 11:40:30 |
合計ジャッジ時間 | 1,512 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 11 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d",&num); | ~~~~~^~~~~~~~~~~ main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d",&leg); | ~~~~~^~~~~~~~~~~
ソースコード
#include <stdio.h>int main(){// 鶴亀の人数int num = 0;scanf("%d",&num);// n番目が数えた足の本数int leg = 0;// 1番目を基準にするint base = 0;// 亀の人数int turtle = 0;// 鶴の人数int crane = 0;int tmp = 0;for(int i = 0;i < num;i++){scanf("%d",&leg);if(i == 0){base = leg;crane++;}else if(leg == base){crane++;}else{turtle++;tmp = leg;}}printf("%d %d",crane,turtle);}