1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int T,n,a,b; 6 while(cin>>T) 7 { 8 while(T--) 9 { 10 cin>>n; 11 int ans=1e+6; 12 for(int i=1; i<=n-1; i++) 13 { 14 cin>>a>>b; 15 ans=min(ans,a+b); 16 } 17 cout<<ans<<endl; 18 } 19 } 20 return 0; 21}Copy the code

 

C. A Captcha Cracker is given a string that identifies 0,2,4,6,9 and the words in the order in which they appear. Number of passes/submissions: 60/62

Two questions in a row because of the stuck when the stuck, the smart question maker, can only say that I did not pay attention to a detail, and then just by the question maker stuck to this point, TL…..

1 #include <bits/stdc++.h> 2 using namespace std; 3 char s[100010]; 4 int main() 5 { 6 int n; 7 scanf("%d",&n); 8 while(n--) 9 { 10 scanf("%s",s); 11 int len=strlen(s); 12 for(int i=0; i<len; i++) 13 { 14 if(s[i]=='0') 15 printf("0"); 16 else if(s[i]=='2') 17 printf("2"); 18 else if(s[i]=='4') 19 printf("4"); 20 else if(s[i]=='6') 21 printf("6"); 22 else if(s[i]=='9') 23 printf("9"); 24 else if(s[i]=='z'&&s[i+1]=='e'&&s[i+2]=='r'&&s[i+3]=='o') 25 printf("0"); 26 else if(s[i]=='t'&&s[i+1]=='w'&&s[i+2]=='o') 27 printf("2"); 28 else if(s[i]=='f'&&s[i+1]=='o'&&s[i+2]=='u'&&s[i+3]=='r') 29 printf("4"); 30 else if(s[i]=='s'&&s[i+1]=='i'&&s[i+2]=='x') 31 printf("6"); 32 else if(s[i]=='n'&&s[i+1]=='i'&&s[i+2]=='n'&&s[i+3]=='e') 33 printf("9"); 34 } 35 printf("\n"); 36 } 37 return 0; 38}Copy the code

 

1 #include <bits/stdc++.h> 2 using namespace std; 3 const double PI = a cosine (1.0); 4 int main() 5 { 6 int n; 7 int a[4]; 8 scanf("%d",&n); 9 while(n--) 10 { 11 for(int i=0; i<3; i++) 12 scanf("%d",&a[i]); 13 sort(a,a+3); 14 printf("%.12lf\n",pi*(pow(a[1],2)+pow((a[2]-a[1]),2))); 15 } 16 return 0; 17}Copy the code

 

Find Quailty given a convex polygon, Find the area of the region that can be reached at no point within the polygon (𝑄) and no further than 𝑈 without entering the polygon. It is not correct to subtract the area of a circle from the intersection of a circle and a convex polygon.

If 𝑄 is not on the boundary, and the tangent of two convex hull is made through 𝑄, the region is divided into two parts, one of which is shown in the figure below. Just calculate the intersection of a circle and a simple polygon, a classic geometric template problem.

The other part of the area is first a big fan, and then along the boundary of the convex polygon from both sides to the other side you get a lot of smaller fans.

If 𝑈 is large enough, some sectors will intersect, and the area of the intersecting part needs to be subtracted

Due to climb from either side of the past on the way to get some small fan is two is empty, so on both sides of the small fan respectively and set intersection is from either side and small fan take the intersection of two sets, then subtract from either side were the result of the enumeration of a small segment intersection, minus on both sides of the small and big fan sector intersection results. It’s O(n^2).

 

 

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define N 100010
 4 unordered_map<string,int> mp;
 5 int n;
 6 bool vis[N];
 7 int main()
 8 {
 9     int T;
10     scanf("%d",&T);
11     while(T--)
12     {
13         memset(vis,0,sizeof(vis));
14         scanf("%d",&n);
15         char opt[5];string name;
16         int x,last=0;
17         mp.clear();
18         int ans=0,cnt=0;
19         while(n--)
20         {
21             scanf("%s",opt);
22             cin>>name;
23             if(opt[0]=='i') mp[name]=++cnt;
24             else
25             {
26                 x=mp[name];
27                 vis[x]=true;
28                 if(x==last+1) ans++;
29                 while(vis[last+1]) ++last;
30             }
31         }
32         printf("%d\n",ans);
33     }
34     return 0;
35 }
Copy the code