其实用数组要更麻烦一些
by 江汨 @ 2020-08-08 11:39:35
@[江汨](/user/226773) 难道用```vector```?
by Andy_chen @ 2020-08-08 11:41:05
你们谁能告诉我怎么改
by jimmyshi29 @ 2020-08-08 11:42:20
```cpp
#include<iostream>
using namespace std;
int n,ans,to;
int main() {
cin>>n;
for(int i=1;i<=n;i++) {
int x,y;
cin>>x>>y;
to=to+x+y-8;
ans+=to;
}
cout<<ans<<'\n';
return 0;
}
```
by _yjh @ 2020-08-08 11:43:19
我的代码
by _yjh @ 2020-08-08 11:43:27
禁止抄袭
by _yjh @ 2020-08-08 11:43:38
第一天的bgx没有减8
by 江汨 @ 2020-08-08 11:44:47
@[_yjh](/user/222104) 感谢大佬,我AC了
by jimmyshi29 @ 2020-08-08 11:47:16
@[jimmyshi29](/user/225837)
```cpp
# include <iostream>
# include <cstdlib>
using namespace std;
int main()
{
int n, a[3010], b[3010], bgx[3010], ans = 0;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i] >> b[i];
if (i == 1) {bgx[i] = a[i] + b[i] -8; continue;}
bgx[i] = bgx[i-1] + ((a[i] + b[i]) - 8);
}
for (int i = 1; i <= n; i++)
{
ans += bgx[i];
}
cout << ans << endl;
return 0;
}
```
by _yjh @ 2020-08-08 11:48:02
你的代码应该这么改
by _yjh @ 2020-08-08 11:48:20