欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

CodeVs 1059 汽车装油

发布时间:2025/3/18 编程问答 45 豆豆
生活随笔 收集整理的这篇文章主要介绍了 CodeVs 1059 汽车装油 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

题目大意:

http://codevs.cn/problem/1059/

 

#include <iostream> #include <cstdio> #include <algorithm>using namespace std;int a[1050] = {0}; int b[1050] = {0};int main() {int n;int count = 0;int res[1050] = {0};scanf("%d" , &n);for(int i = 0; i < n; i++)scanf("%d" , &a[i]);for(int i = 0; i < n; i++)scanf("%d",&b[i]);int total = 0;int flag = 0;for(int j = 0; j < n; j++){int tmpn = n;int tmpj = j;while(tmpn-- != 0){total += a[tmpj];if(total - b[tmpj] >= 0){flag++;total -= b[tmpj];}elsebreak;if(tmpj == n-1)tmpj = 0;elsetmpj++;}if(flag == n)res[count++] = j+1;total = 0;flag = 0;}if(count == 0)cout << "No Result!" << endl;else{sort(res,res+count);for(int i = 0; i < count; i++){cout << res[i] << " ";}}return 0; }

 

转载于:https://www.cnblogs.com/zyqBlog/p/7448438.html

总结

以上是生活随笔为你收集整理的CodeVs 1059 汽车装油的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。