結果
問題 |
No.112 ややこしい鶴亀算
|
ユーザー |
![]() |
提出日時 | 2025-03-06 11:39:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 528 bytes |
コンパイル時間 | 585 ms |
コンパイル使用メモリ | 27,008 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-06 11:39:30 |
合計ジャッジ時間 | 1,533 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 WA * 5 |
コンパイルメッセージ
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; } } if(base < tmp){ printf("%d %d",turtle,crane); }else{ printf("%d %d",crane,turtle); } }