hihocoder Arithmetic Expression【在線查詢】
阿新 • • 發佈:2017-11-28
limit 時間 cout main ins font multipl exp 限制
Arithmetic Expression
時間限制:2000ms
單點時限:200ms
內存限制:256MB
描述
Given N arithmetic expressions, can you tell whose result is closest to 9?
輸入
Line 1: N (1 <= N <= 50000).
Line 2..N+1: Each line contains an expression in the format of "a op b" where a, b are integers (-10000 <= a, b <= 10000) and op is one of addition (+), subtraction (-), multiplication (*) and division (/). There is no "divided by zero" expression.
輸出
The index of expression whose result is closest to 9. If there are more than one such expressions, output the smallest index.
- 樣例輸入
-
4 901 / 100 3 * 3 2 + 6 8 - -1
- 樣例輸出
-
2
【題意】:算出的結果最接近9的為第幾個,相同的話輸出靠前的。註意卡精度!要用double~
【代碼】:#include <bits/stdc++.h> #define LL long long #define
打擂臺 嚴格小於
hihocoder Arithmetic Expression【在線查詢】