結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2016-05-03 19:15:40 |
言語 | C90 (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 552 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-10-05 05:06:14 |
合計ジャッジ時間 | 5,396 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 4 WA * 5 RE * 11 TLE * 1 -- * 2 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:19:17: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[100001]’ [-Wformat=] 19 | scanf("%s", &s); | ~^ ~~ | | | | | char (*)[100001] | char * main.c:21:26: warning: comparison between pointer and integer 21 | for( i = 0; s[i] != NULL; i++) { | ^~ main.c:25:26: warning: comparison between pointer and integer 25 | for( i = 0; s[i] != NULL; i++) { | ^~ main.c:28:44: warning: comparison between pointer and integer 28 | for( j = i+1; s[j] != NULL; j++) { | ^~ main.c:19:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%s", &s); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int factorial(int x) { if( x == 0 ) return 1; return x * factorial(x-1); } int combi(int c) { if( c < 2 ) return 0; return factorial(c) / ( factorial(c-2) * factorial(2) ); } int main(void) { int i, j, sum = 0, wc = 0; char s[100001]; scanf("%s", &s); for( i = 0; s[i] != NULL; i++) { if( s[i] == 'w' ) wc++; } for( i = 0; s[i] != NULL; i++) { if( s[i] == 'c' ) { int cc = 0; for( j = i+1; s[j] != NULL; j++) { if( s[j] == 'w' ) cc++; } sum += combi(cc); } } printf("%d\n", sum); return 0; }