結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
kapo
|
| 提出日時 | 2016-05-04 05:55:20 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 392 bytes |
| コンパイル時間 | 395 ms |
| コンパイル使用メモリ | 21,504 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-05 06:17:13 |
| 合計ジャッジ時間 | 982 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
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;
long long sum = 0, wc = 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