結果
| 問題 |
No.265 数学のテスト
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2015-08-07 23:43:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 107 ms / 2,000 ms |
| コード長 | 1,124 bytes |
| コンパイル時間 | 1,110 ms |
| コンパイル使用メモリ | 160,576 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 11:23:41 |
| 合計ジャッジ時間 | 2,130 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%s", str);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#include <stdint.h>
#include <sys/time.h>
char str[65536];
long n;
long a[16];
int main() {
long d;
long depth = 0;
std::cin >> n >> d;
scanf("%s", str);
for(long i = 0; i <= n; ++i) {
if( str[i] == '{' ) {
depth += 1;
continue;
}
if( str[i] == '}' ) {
depth -= 1;
continue;
}
if( str[i] == 'x' || ( '0' <= str[i] && str[i] <= '9' ) ) {
long temp = 1;
long red = 0;
for(long j = i; j <= n; ++j) {
if( '0' <= str[j] && str[j] <= '9' ) {
temp = str[j] - '0';
red += 1;
continue;
}
if( str[j] == '+' || str[j] == '}' || str[j] == '\0' ) {
long d = (j-i+1)/2-red;
for(long k = 0; k < depth; ++k) {
temp *= d;
d -= 1;
}
if( (j-i+1)/2-depth-red >= 0 ) {
a[(j-i+1)/2-depth-red] += temp;
}
i = j-1;
break;
}
}
continue;
}
}
for(long i = 0; i < d; ++i) {
std::cout << a[i] << " ";
}
std::cout << a[d] << std::endl;
return 0;
}
alpha_virginis