結果
| 問題 |
No.265 数学のテスト
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2015-08-07 23:25:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,114 bytes |
| コンパイル時間 | 1,409 ms |
| コンパイル使用メモリ | 159,208 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 05:23:56 |
| 合計ジャッジ時間 | 2,441 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 WA * 1 |
コンパイルメッセージ
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];
int n;
int a[16];
int main() {
int d;
int depth = 0;
std::cin >> n >> d;
scanf("%s", str);
for(int 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' ) ) {
int temp = 1;
int red = 0;;
for(int 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' ) {
int d = (j-i+1)/2-red;
for(int 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(int i = 0; i < d; ++i) {
std::cout << a[i] << " ";
}
std::cout << a[d] << std::endl;
return 0;
}
alpha_virginis