ACM 刷题

原题:https://codeforces.com/gym/103480/problem/B

(7的意志)

直接使用暴力递归计算即可,思路还是简单的

 1 #include <bits/stdc++.h>
 2 #define int long long
 3 const int inf = 0x3f3f3f3f;
 4 #define Blizzard std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 5 using namespace std;
 6 //*******************
 7 const int N = 1e5 + 3;
 8 int num[N];
 9 
10 //********************
11 
12 void solve()
13 {
14     int n;
15     cin >> n;
16     int cnt = 0;
17     for (int i = 0; i < n; i++)
18         cin >> num[i];
19     int l = 0, r = 0;
20     int to = num[0];
21     while (r < n)
22     {
23         if (to < 7777)
24         {
25             r++;
26             if (r >= n)
27                 break;
28             to += num[r];
29         }
30         else if (to > 7777)
31         {
32             to -= num[l];
33             l++;
34         }
35         else // to ==7777
36         {
37             cnt++;
38             to -= num[l];
39             l++;
40         }
41     }
42     cout << cnt << endl;
43 }
44 
45 signed main()
46 {
47     Blizzard;
48     int t = 1;
49     cin >> t;
50     while (t--)
51     {
52         solve();
53     }
54     return 0;
55 }
//队友的代码啦,自己写的太屎山,就不贴我的了 不过思路差不多的

 

posted @ 2024-03-04 21:41  Blizzard1900  阅读(9)  评论(0)    收藏  举报