10 条题解
-
9
C++
#include <iostream> #include <vector> #include <numeric> using namespace std; int main() { int a,b; cin>>a>>b; vector<int> va = {a}; vector<int> vb = {b}; vector<int> vab = {b, a}; vector<int> w(2); int sum = accumulate(vab.begin(), vab.end(), 0); adjacent_difference(vab.begin(), vab.end(), w.begin()); int sub = w[1]; int mul = inner_product(va.begin(), va.end(), vb.begin(), 0); cout<<sum<<' '<<sub<<' '<<mul<<endl; return 0; }
Python
eval
a, b = map(int, input().split()) u = eval(f"{a}{chr(43)}{b}") v = eval(f"{a}{chr(45)}{b}") w = eval(f"{a}{chr(42)}{b}") print(u, v, w)
利用复数搞负数
a, b = map(int, input().split()) cp = complex(0, b) cp = cp.conjugate() ls1 = [a, b] ls2 = [a, int(cp.imag)] ls3 = [a for i in range(b)] print(sum(ls1), sum(ls2), sum(ls3))
find 搞负数 Fraction 搞除法
from fractions import Fraction a, b = map(int, input().split()) f = "".find("233") ls1 = [a, b] ls2 = [a, Fraction(b, f)] mul = Fraction(a, Fraction(1, b)) print(sum(ls1), sum(ls2), mul)
信息
- ID
- 246
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 2
- 标签
- (无)
- 递交数
- 254
- 已通过
- 60
- 上传者