1 #include<stdio.h> 2 #include<string.h> 3 #define MAXN 105 4 using namespace std; 5 int main() 6 { 7 int r, y, g; 8 int n; 9 int k, t; 10 int ans = 0; 11 scanf("%d%d%d", &r, &y, &g); 12 scanf("%d", &n); 13 for (int i = 0; i < n; i++) 14 { 15 scanf("%d%d", &k, &t); 16 if (k == 0) ans += t; 17 else if (k == 1) 18 { 19 ans += t; 20 } 21 else if (k == 2) 22 { 23 ans += t; 24 ans += r; 25 } 26 } 27 printf("%d\n", ans); 28 return 0; 29 }
博客给出了CCF 201812 - 1小明上学问题的代码实现。代码使用C++语言,通过输入红绿灯时间和路况信息,计算小明上学所需时间,最后输出结果。
7530

被折叠的 条评论
为什么被折叠?



