# November 12, 2021 (2018 CCPC Jilin station)

Posted by sumeet on Tue, 16 Nov 2021 09:49:39 +0100

## A - The Fool

Meaning:

For a number n, you need to find the sum of n/1+n/2+...+n/n, judge whether the sum is odd or even, and output.

Idea:

It can be found that the first three numbers are odd, five are even, seven are odd and nine are even, that is, the equal difference sequence with tolerance of 2. It can be found that 3,5,7,9, and 1-3 is greater than or equal to the square of 1, less than the square of 2, 4-8 is greater than or equal to the square of 2, less than the square of 3, 9-15   That is, greater than or equal to the square of 3 and less than the square of 4. So you can judge directly by sqrt (n), or Look here.

code:

```#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int t;
cin>>t;
for(int i=1; i<=t; i++)
{
long long n;
cin>>n;
n=sqrt(n);
if(n%2==0)
cout<<"Case "<<i<<""<<": even"<<endl;

else
cout<<"Case "<<i<<""<<": odd"<<endl;
}
}
```

## B - The World

Meaning:

The world can direct world travel, especially large-scale travel. You may be lucky to start a six-month overseas trip, or work, study or live abroad for a long time. Similarly, this card strengthens universal understanding and global awareness, and you will have a new appreciation for people and cultures from all over the world.

There are different time zones all over the world, resulting in jet lag. Here, you can learn about several famous capitals and their corresponding time zones.

Beijing - China - UTC+8 (China standard time)

Washington - United States - UTC-5 (Eastern standard time)

London UK UTC (Greenwich mean time)

Moscow Russia UTC+3 (Moscow time)

Given the local time of a city, you need to calculate the date and local time of another specific city in the above capital.

Idea:

The value range of hours is 1 to 12, 12:00 in the middle of the night is 12:00AM, and 12:00 at noon is 12:00PM. And midnight is the beginning of a new day.

After time conversion, a clock greater than or equal to 24 indicates that it is in Tomorrow, and if less than 0 indicates that it is in Yesterday.

code:

```#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
string a,b,p;
int main()
{
mp["Beijing"]=8;
mp["Washington"]=-5;
mp["London"]=0;
mp["Moscow"]=3;
int TT=0;
int T;scanf("%d",&T);
int h,m;
while(T--)
{
scanf("%d:%d",&h,&m);
cin>>p;
if(p=="PM"&&h!=12)
h+=12;
if(p=="AM"&&h==12)
h-=12;
cin>>a>>b;
h+=(mp[b]-mp[a]);
printf("Case %d: ",++TT);
if(h>=24)
{printf("Tomorrow ");h-=24;}
else if(h<0)
{printf("Yesterday ");h+=24;}
else
printf("Today ");
if(h>12)
printf("%d:%02d ",h-12,m);
else if(h>0)
printf("%d:%02d ",h,m);
else
printf("12:%02d ",m);
if(h>=12)
printf("PM\n");
else
printf("AM\n");
}
return 0;
}```

## C - Justice

Meaning:

t group of examples, one n in each group of examples, and then input n numbers ki, each of which you should regard as one part of the power of ki of 2. Ask whether you can divide these numbers into two groups, and make the sum of the two groups greater than or equal to 1 / 2. NO can be output. If you can, output YES, and output which group these numbers are divided into in the next line. The group numbers of the two groups are 0 and 1.

Idea:

Divided into two piles, the same numbers can be merged into a new one, and then the QAQ will not be written. Read other people's solutions

Explain here why you want to merge 1, because you merge the final required results. Both groups are greater than or equal to 1 / 2. The denominator, that is, the first power of 2, is the boundary of success. It is YES only when the sum sorted out by n numbers is less than or equal to 1. The second is more detailed.

First kind

Second

code:

```#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int, int> VII;
#define inf 0x3f3f3f3f
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll MAXN = 1e5 + 7;
const ll MAXM = 1e5 + 7;
const ll MOD = 1e9 + 7;
const double eps = 1e-6;
const double pi = acos(-1.0);
int vis[MAXN];
PII a[MAXN];
int main()
{
int t;
scanf("%d", &t);
for (int Case = 1; Case <= t; Case++)
{
memset(vis, 0, sizeof(vis));
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i].first), a[i].second = i;
sort(a + 1, a + 1 + n);
int pre = 1;
int cnt1 = 1, cnt2 = 1;
bool flag = true;
for (int i = 1; i <= n; i++)
{
while (pre < a[i].first && cnt1 + cnt2 <= n - i + 1)
{
cnt1 <<= 1;
cnt2 <<= 1;
pre++;
}
if (cnt1 + cnt2 > n - i + 1)
{
flag = false;
break;
}
if (cnt1)
{
cnt1--;
vis[a[i].second] = 1;
}
else
cnt2--;
if (!cnt1 && !cnt2)
break;
}
printf("Case %d: ", Case);
if (flag)
{
printf("YES\n");
for (int i = 1; i <= n; i++)
printf("%d", vis[i]);
printf("\n");
}
else
printf("NO\n");
}
return 0;
}```

## F - The Hermit

Meaning:

For each point i, its coverage is [i - ri + 1, i + ri - 1], and for any adjacent point i, i + 1, the left boundary of the coverage of i + 1 must be greater than or equal to the left boundary of i coverage. For each point i, its weight is defined as the number of legal K, which is defined as K legal: K < i, K is within the coverage of i, and there is a point j, K < j < i, and dist (k, j) > = dist (j, i), and i and K are within the coverage of j. the weight XOR and sum of each point are required

Idea:

For points with RI < 3, the weight is obviously 0. For points with RI > = 3, we get from the question that the left boundary covered by ri - 1 must be < = the left boundary covered by RI, that is, i set j = i - 1, and other points that can be covered on the left of i can be used as legal k points, that is, the weight value of i is ri - 2.
code:

```#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e6 + 10, N = 1e6;
int main() {
int T, kase = 0;
scanf("%d", &T);
while (T--) {
int n, x, ans = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &x);
if (x >= 3)
ans ^= (x - 2);
}
printf("Case %d: %d\n", ++kase, ans);
}
}
```

Topics: C++