目录
A Addition and Subtraction Easy
B Contest with Drinks Easy
C Lining Up
D Xor Sum
A | B | C | D |
---|---|---|---|
√ | √ | ● | ● |
( √:做出; ●:尝试未做出; ○:已补题 )
题目地址:https://atcoder.jp/contests/abc050
T1:
题意:输入两个数和一个字符(字符只能是+或-),输出a+b或a-b
思路:同上
代码:
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
int a,b;
char c;
cin>>a>>c>>b;
if(c=='+') cout<<a+b;
else cout<<a-b;
return 0;
}
T2:
题意:n个题目,分别需要Ti时间来解答;m个饮料,喝下会使得某题时间变成Pi,需要计算选择每个饮料后的总时间
思路:先把原来数组的总和求出来,然后用和减去被换的数的值再加上要换成的数的值
代码:
#include <iostream>
using namespace std;
typedef long long ll;
const int N=110;
int n,m;
int t[N];
int sum;
int main()
{
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>t[i];
sum+=t[i];
}
cin>>m;
while(m--)
{
int i,v;
cin>>i>>v;
cout<<sum-t[i]+v<< endl;
}
return 0;
}