include <bits/stdc++.h>
using namespace std;
struct Node {
string sdt;
string hoten;
Node next;
};
Node first;
void insert(Node &first, string sdt, string hoten) { for (Node p = first; p != NULL; p = p->next) { if (p->sdt == sdt) return; } Node *q = new Node; q->sdt = sdt; q->hoten = hoten; q->next = first; first = q; }
void count(Node first) { int d = 0; for (Node p = first; p != NULL; p = p->next) d++; cout << d << "\n"; }
void find(Node first, string sdt) { for (Node p = first; p != NULL; p = p->next) { if (p->sdt == sdt) { cout << p->hoten << " " << p->sdt << "\n"; return; } } cout << "Not found\n"; }
void del(Node &first, string sdt) { Node p = first, *truoc = NULL; while (p != NULL) { if (p->sdt == sdt) { if (truoc == NULL) first = p->next; else truoc->next = p->next; delete p; return; } truoc = p; p = p->next; } }
int main() { string s; while (cin >> s) { if (s == "insert") { string sdt, hoten; cin >> sdt; cin.ignore(); getline(cin, hoten); insert(first, sdt, hoten); } else if (s == "count") { count(first); } else if (s == "find") { string sdt; cin >> sdt; find(first, sdt); } else if (s == "del") { string sdt; cin >> sdt; del(first, sdt); } else if (s == "fin") { return 0; } } } #include <bits/stdc++.h> using namespace std;
int main() { long long M; long long n; cin >> M >> n; long long a[n];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
int s = 0;
for (int i = 0; i < n; i++)
{
s += a[i];
}
long long tienthua = M - s;
long long nho = a[0];
for (int i = 1; i < n; i++)
{
if (a[i] < nho)
nho = a[i];
}
long long them = tienthua / nho;
cout << n + them << endl;
return 0;
}
From Hue University of Sciences
| Sun |
|---|
| Mon |
| Tues |
| Wed |
| Thurs |
| Fri |
| Sat |
| Less | More | |||||
|---|---|---|---|---|---|---|