码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #473 (Div. 2)

时间:2018-04-08 18:19:51      阅读:405      评论:0      收藏:0      [点我收藏+]

标签:ifd   AC   span   sha   task   ios   bad   syn   opened   

=====》【补题: F 】《=====


 

A. Mahmoud and Ehab and the even-odd game

技术分享图片
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define fre(i,t,n)  for(int i =(t);i<=(n);++i)
 4 #define fer(i,n,t)  for(int i =(n);i>=(t);--i)
 5 #define mp make_pair
 6 #define pb push_back
 7 typedef long long ll;
 8 void smain();
 9 int main(){
10     ios::sync_with_stdio(false);
11     smain();
12     return 0;
13 }
14 void smain(){
15     int n;
16     cin>>n;
17     if(n%2==0)  cout<<"Mahmoud";
18     else cout<<"Ehab";
19     cout<<endl;
20 }
View Code

 

B. Mahmoud and Ehab and the message

技术分享图片
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define fre(i,t,n)  for(int i =(t);i<=(n);++i)
 4 #define fer(i,n,t)  for(int i =(n);i>=(t);--i)
 5 #define mp make_pair
 6 #define pb push_back
 7 typedef long long ll;
 8 void smain();
 9 int main(){
10     ios::sync_with_stdio(false);
11     smain();
12     return 0;
13 }
14 map<string,int> M;
15 const int MAXN = 1e5+10;
16 const ll INF = 2e9;
17 string str[MAXN];
18 ll cost[MAXN];
19 int tmp[MAXN];
20 void smain(){
21     int n,k,m;
22     cin>>n>>k>>m;
23     fre(i,1,n)
24     {
25         cin>>str[i];
26         M[str[i]]=i;
27     }
28     fre(i,1,n)
29     {
30         cin>>cost[i];
31     }
32     fre(i,1,k)
33     {
34         int K;
35         cin>>K;
36         ll mc=INF;
37         fre(j,1,K)
38         {
39             cin>>tmp[j];
40             mc=min(mc,cost[tmp[j]]);
41         }
42         fre(j,1,K)
43             cost[tmp[j]]=mc;
44     }
45     string s;
46     ll ans=0;
47     fre(i,1,m)
48     {
49         cin>>s;
50         ans+=cost[M[s]];
51     }
52     cout<<ans<<endl;
53 }
View Code

 

C. Mahmoud and Ehab and the wrong algorithm

技术分享图片
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define fre(i,t,n)  for(int i =(t);i<=(n);++i)
 4 #define fer(i,n,t)  for(int i =(n);i>=(t);--i)
 5 #define mp make_pair
 6 #define pb push_back
 7 typedef long long ll;
 8 void smain();
 9 int main(){
10     ios::sync_with_stdio(false);
11     smain();
12     return 0;
13 }
14 void smain(){
15     int n;
16     cin>>n;
17     if(n<=5)
18     {
19         cout<<-1<<endl;
20     }
21     else
22     {
23         for(int i=2;i<=n;i+=2)
24             cout<<"1 "<<i<<endl;
25         for(int i=3;i<=n;i+=2)
26             cout<<"2 "<<i<<endl;
27     }
28     for(int i=2;i<=n;++i)
29         cout<<"1 "<<i<<endl;
30 }
View Code

 

D. Mahmoud and Ehab and another array construction task

技术分享图片
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define fre(i,t,n)  for(int i =(t);i<=(n);++i)
 4 #define fer(i,n,t)  for(int i =(n);i>=(t);--i)
 5 #define mp make_pair
 6 #define pb push_back
 7 //#define fuckoj
 8 typedef long long ll;
 9 void smain();
10 int main(){
11     ios::sync_with_stdio(false);
12 
13     #ifdef fuckoj
14     freopen("d.in","r",stdin);
15     #endif // fuckoj
16     smain();
17     return 0;
18 }
19 const int MAXN = 2e6+10;
20 bool isNotPrime[MAXN];
21 int prime[MAXN];
22 bool Out[MAXN];
23 int tot=0;
24 set<int> Set;
25 void Shai()
26 {
27     int L=2e6+1;
28     fre(i,2,L)
29     {
30         if(!isNotPrime[i])  prime[tot++]=i;
31         for(int j=0;j<tot&&(ll)prime[j]*i<MAXN;++j){
32             isNotPrime[i*prime[j]]=true;
33             if(i%prime[j]==0)   break;
34         }
35     }
36 }
37 void Clear(int x)
38 {
39     for(int g=x;g<MAXN;g+=x)
40     {
41         Set.erase(g);
42     }
43 }
44 void XX(int g)
45 {
46     fre(i,0,tot-1)
47     {
48         if(prime[i]>g)  break;
49         if(g%prime[i]==0)
50         {
51             Clear(prime[i]);
52             Out[i]=true;
53             while(g%prime[i])   g%=prime[i];
54         }
55     }
56 }
57 void smain()
58 {
59     Shai();
60     fre(i,2,MAXN-1)
61         Set.insert(i);
62     int n,d;
63     cin>>n;
64     bool flag=false;
65     int k=0;
66     fre(i,1,n)
67     {
68         cin>>d;
69         if(flag)
70         {
71             while(Out[k])   k++;
72             Out[k]=true;
73             cout<<prime[k]<<" ";
74         }else{
75             auto iter=Set.lower_bound(d);
76             if(*iter>d) flag=true;
77             cout<<*iter<<" ";
78             XX(*iter);
79         }
80     }
81 }
View Code

 

E. Mahmoud and Ehab and the xor-MST

技术分享图片
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define fre(i,t,n)  for(int i =(t);i<=(n);++i)
 4 #define fer(i,n,t)  for(int i =(n);i>=(t);--i)
 5 #define mp make_pair
 6 #define pb push_back
 7 typedef long long ll;
 8 void smain();
 9 int main(){
10     ios::sync_with_stdio(false);
11     smain();
12     return 0;
13 }
14 ll pow(ll k){
15     ll ans=1,now=2;
16     //cout<<"pow("<<k<<")=";
17     while(k){
18         if(k&1) ans*=now;
19         k>>=1ll;
20         now*=now;
21     }
22     //cout<<ans<<endl;
23     return ans;
24 }
25 void smain(){
26     ll n;
27     cin>>n;
28     ll t=n-1;
29     ll ans=0;
30     ll ai=1;
31     int i=0;
32     fre(i,0,62){
33         ans+=(t/pow(i)+1)/2*pow(i);
34     }
35     cout<<ans<<endl;
36 }
View Code

 

F. Mahmoud and Ehab and yet another xor task

 


最近补题较多,题解就懒得写了 = - = 如果有需要的可以留个评论或者私下联系


 

版权所有:scidylanpno
原文链接:http://www.cnblogs.com/scidylanpno/p/8745823.html

 

Codeforces Round #473 (Div. 2)

标签:ifd   AC   span   sha   task   ios   bad   syn   opened   

原文地址:https://www.cnblogs.com/scidylanpno/p/8745823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!