結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-10-12 22:19:02 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 20,608 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:54:07 |
合計ジャッジ時間 | 949 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:17:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%s", in); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> char in[101]; int count(int i){ int p = 1, a = 1; while(in[i] != '\0'){ a++; if(in[i]=='w') if(p==1) p++; else return a; i++; } return 101; } int main(){ int ans = 101, i = 0, c; scanf("%s", in); while(in[i] != '\0'){ if(in[i] == 'c'){ c = count(i + 1); if(c < ans) ans = c; } i++; } if(ans == 101) ans = -1; printf("%d\n", ans); return 0; }