結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kapo
                         | 
                    
| 提出日時 | 2016-05-04 05:49:17 | 
| 言語 | C90  (gcc 12.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 390 bytes | 
| コンパイル時間 | 409 ms | 
| コンパイル使用メモリ | 21,120 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-05 06:17:02 | 
| 合計ジャッジ時間 | 1,048 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 WA * 2 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:13: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[100001]’ [-Wformat=]
    9 |     scanf("%s", &s);
      |            ~^   ~~
      |             |   |
      |             |   char (*)[100001]
      |             char *
main.c:9:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%s", &s);
      |     ^~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
#include <string.h>
int main(void)
{
    int i, j, l, wc=0;
    long long sum = 0;
    char s[100001];
    scanf("%s", &s);
	l = (int)strlen(s);
    for( i = l-1; l >= 0; l--) {
        if( s[l] == 'w' ) {
			wc++;
        } else if ( s[l] == 'c' ) {
			if( wc >= 2 ) {
				sum += (wc * (wc-1) /2 );
			}
        }
    }
    
    printf("%lld\n", sum);
    return 0;
}
            
            
            
        
            
kapo