# A.空间

1MB = 1024KB
1KB = 1024B

``````256 * 1024 * 1024 / 4 = 67108864
``````

# B.卡片

``````int a[10] = {2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021};

int main()
{
for (int i = 1; i; i ++ ){
int t = i;
while (t){
int s = t % 10;
if(a[s] >= 1) a[s] --;
else{
cout << i - 1 << endl;
return 0;
}
t /= 10;
}
}
}
``````

# C.直线

k = (y2-y1) / (x2-x1)
b = (x2 * y1 - y2 * x1) / (x2 - x1)

``````typedef pair<double, double>PII;

map<PII, bool>mp;

int main()
{
for (int x1 = 0; x1 < 20; x1 ++ ){
for (int y1 = 0; y1 < 21; y1 ++ ){
for (int x2 = 0; x2 < 20; x2 ++ ){
for (int y2 = 0; y2 < 20; y2 ++ ){
if(x1 == x2) continue;
double k = (double)(y2 - y1) / (double)(x2 - x1);
double b = (double)(x2 * y1 - y2 * x1) / (x2 - x1);
mp[{k, b}] = true;
}
}
}
}

cout << mp.size() + 21;
}
``````

# D.货物摆放

``````void get_divisors()
{
for (int i = 1; i <= N / i; i ++ ){
if(N % i == 0)
{
if(i == N / i) a[t ++] = i;
else{
a[t ++] = i;
a[t ++] = N / i;
}
}
}
}
``````

``````sort(a, a + t);
int ans = 0;
for (int i = 0; i < t; i ++ ){
for (int j = 0; j < t; j ++ ){
if(a[i] * a[j] > N) break;
for (int k = 0; k < t; k ++ ){
if(a[i] * a[j] * a[k] == N) ans ++;
}
}
}
``````

# E.路径

：先建图，再跑一边dijkstra / spfa / floyd就可以

``````void add(int a, int b)
{
int c;
c = a * b / __gcd(a, b);
e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx ++;
}

int main()
{
memset(h, -1, sizeof h);
for (int i = 1; i < 2021; i ++ ){
for (int j = i; j <= i + 21; j ++ ){
}
}
}
``````

``````void spfa()
{
memset(dist, 0x3f, sizeof dist);
dist[1] = 0;
st[1] = true;
queue<int>q;
q.push(1);
while (q.size())
{
int t = q.front();
q.pop();

st[t] = false;

for (int i = h[t]; i != -1; i = ne[i]){
int j = e[i];
if(dist[j] > dist[t] + w[i]){
dist[j] = dist[t] + w[i];
if(!st[j]){
st[j] = true;
q.push(j);
}
}
}
}
cout << dist[2021];
}
``````

F.时间显示

``````	long long n;
cin >> n;
int days = 1000 * 60 * 60 * 24;
n -= n / days * days;
``````

``````	int s = n / 1000; //多少秒
int min = s / 60; //多少分钟
int hour = min / 60; //多少小时

s %= 60;
min %= 60;
hour %= 24;

if(hour < 10) cout << 0;
cout << hour << ':';
if(min < 10) cout << 0;
cout << min << ':';
if(s < 10) cout << 0;
cout << s;
``````

# G.砝码称重

``````	cin >> n;
int sum = 0;
for (int i = 1; i <= n; i ++ ){
cin >> a[i];
sum += a[i];
}

f[0][0] = 1;
for (int i = 1; i <= n; i ++ ){
for (int j = 0; j <= sum; j ++ ){
f[i][j] = f[i - 1][abs(j - a[i])] + f[i - 1][j] + f[i - 1][abs(j + a[i])];
}
}
``````

``````	int ans = 0;
for (int i = 1; i <= sum; i ++ ){
if(f[n][i]) ans ++;
}
cout << ans;
``````

THE END