-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCF-2051B.cpp
More file actions
176 lines (87 loc) · 3.6 KB
/
Copy pathCF-2051B.cpp
File metadata and controls
176 lines (87 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// my portfolio => https://abdul-muyeed.github.io/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl '\n';
#define ln cout<<endl;
#define YES print("YES")
#define NO print("NO")
#define ll long long
#define lll __int128_t
#define ull unsigned long long
#define all(V) V.begin(),V.end()
#define pb push_back
#define ff first
#define ss second
#define fo(i,n) for(int i=0;i<n;i++)
#define foi(i,a,n) for(int i=a;i<n;i++)
#define print(A) cout<< A <<endl;
#define elif else if
#define sz(x) ((ll)(x).size())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define count(a,x) count(a.begin(), a.end(),x)
#define sum(a) accumulate(a.begin(), a.end(),0)
#define maxl(A) max_element(all(A))
#define minl(A) min_element(all(A))
#define imax INT_MAX;
#define imin INT_MIN;
#define umap unordered_map
#define uset unordered_set
#define bcount __builtin_popcountll
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x<< " " << x << endl;
#define debugs(x) cerr << #x<< " "; _print(x);
#define debuga(x,n) cerr << #x<< " "; _printa(x,n);
#else
#define debug(x)
#define debugs(x)
#endif
template<class T>void _print(vector<T>v) {cerr << "[ "; for (T out : v) {cerr << out << " ";} cerr << "]" << endl;}
template<class T, class V>void _print(map<T, V>v) {cerr << "[ "; for (auto &out : v) {cerr << "(" << out.ff << "," << out.ss << ")" << " ";} cerr << "]" << endl;}
template<class T, class V>void _print(vector<pair<T, V>>v) {cerr << "[ "; for (auto &out : v) {cerr << "(" << out.ff << "," << out.ss << ")" << " ";} cerr << "]" << endl;}
template<class T, class V>void _print(unordered_map<T, V>v) {cerr << "[ "; for (auto &out : v) {cerr << "(" << out.ff << "," << out.ss << ")" << " ";} cerr << "]" << endl;}
template<class T>void _print(unordered_set<T>v) {cerr << "[ "; for (T out : v) {cerr << out << " ";} cerr << "]" << endl;}
template<class T>void _print(set<T>v) {cerr << "[ "; for (T out : v) {cerr << out << " ";} cerr << "]" << endl;}
template<class T, class V>void _printa(T arr[],V n){cerr<<"[ ";fo(i,n){cerr<< arr[i]<<" ";}cerr<<"]"<<endl;}
//template<class T>void _print(vector<T>v){cerr<<"[ ";for(T out:v){cerr<<out<<" ";}cerr<<"]"<<endl;}
// const ll M =109546051211;
// const ll N =1e7+3;
// ll arr[10][31];
// const long double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128;
// vector<int> vertex[55];
// bool visited[10000000]={0};
// ll dis[10000000]={0};
// queue<ll> q;
ll maxi=INT_MAX;
ll ans=INT_MAX;
// const ll MOD = 1e9 + 7;
// const ll MAX_N = 1000;
// vector<vector<ll>> C(MAX_N + 1, vector<ll>(MAX_N + 1, 0));
void init() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif
}
void solve(){
ll n,a,b,c;cin>>n>>a>>b>>c;
if(n-a < 1 ){print(1) return;}
if(n-a-b < 1 ){print(2) return;}
if(n-a-b-c < 1 ){print(3) return;}
ll sum = a+b+c;
ll ans=n/sum;
n=n%sum;
if(n==0){print(ans*3) return;}
if(n-a < 1 ){print(ans*3+1) return;}
if(n-a-b < 1 ){print(ans*3+2) return;}
if(n-a-b-c < 1 ){print(ans*3+3) return;}
}
int main(){init();ll t=1;
cin>>t;
while(t--){solve();}return 0;}