結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
ReERishun
|
| 提出日時 | 2020-05-10 02:18:26 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,128 bytes |
| コンパイル時間 | 278 ms |
| コンパイル使用メモリ | 30,208 KB |
| 実行使用メモリ | 8,476 KB |
| 最終ジャッジ日時 | 2024-07-06 12:57:14 |
| 合計ジャッジ時間 | 6,815 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 TLE * 1 -- * 7 |
ソースコード
#include<stdio.h>
typedef unsigned short ushort;
void numin(ushort index, ushort *numBox) {
char str;
for (ushort i = 0; i<index; i++)
numBox[i] = 0;
ushort cnt = 0;
while (cnt < index) {
str = getchar();
if (str == '\n') {
if (cnt != 0)
break;
}
else if (str < '0' || str > '9')
cnt++;
else
numBox[cnt] = numBox[cnt] * 10 + (ushort)str - (ushort)'0';
}
}
int main() {
ushort number=0;
ushort total =0;
ushort value[50];
// 入力処理
scanf("%hu", &number);
scanf("%hu", &total);
numin(number, value);
ushort ans = value[0];
ushort cnt = 0;
unsigned long long switcher = 0;
// 計算処理
while (1) {
// 計算
if ((switcher >> cnt) & 1)
ans *= value[cnt + 1];
else
ans += value[cnt + 1];
if (ans >= total) {
if (ans == total && cnt == number - 2)
break;
else {
ans = value[0];
cnt = 0;
switcher++;
}
}
else if (cnt < number - 2) {
cnt++;
}
else {
ans = value[0];
cnt = 0;
switcher++;
}
}
for (int i = 0; i < number - 1; i++) {
if((switcher >> i) & 1)
printf("*");
else
printf("+");
}
return 0;
}
ReERishun