题解:P15638 [ICPC 2022 Tehran R] Final Price

· · 题解

P15638 [ICPC 2022 Tehran R] Final Price 题解

非常简单的题目,这种题目的题解竟然被我水到了。

思路分析

  1. 数据读取:第一行输入天数 n ,第二行输入初始价格,接下来 n-1 行输入每日价格变化;
  2. 计算过程:将初始价格与所有价格变化累加即可。 ::::success[code]
    
    #include <bits/stdc++.h>
    using namespace std;

define int long long

signed main(){ ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);

int n;  //天数 
cin >> n;

int ans = 0;   //用来累加 
while(n--){
    int x;
    cin >> x;
    ans += x;  //将初始价格和每日变化累加
}

cout << ans;  //输出最终价格

return 0;

}


::::
求管理员审核通过,求各位点赞评论加关注再走吧qwq。