首页 > 代码库 > Codeforces 400 Div.1+Div.2

Codeforces 400 Div.1+Div.2

A. A Serial Killer
 
Examples
Input
ross rachel
4
ross joey
rachel phoebe
phoebe monica
monica chandler
Output
ross rachel
joey rachel
joey phoebe
joey monica
joey chandler
Input
icm codeforces
1
codeforces technex
Output
icm codeforces
icm technex
题意:求每天存活的人,下两个人中,只要判断第一个的相等情况,水题
技术分享
 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 
 5 string s1,s2;
 6 string t1,t2;
 7 int n;
 8 
 9 int main()
10 {
11     cin>>s1>>s2;
12     cin>>n;
13 
14     for(int i=0;i<=n;i++)
15     {
16         cout<<s1<<" "<<s2<<endl;
17         if(i!=n)cin>>t1>>t2;
18         if(t1==s1)s1=t2;
19         else s2=t2;
20     }
21     return 0;
22 }
View Code

 

B. Sherlock and his girlfriend
Examples
Input
3
Output
2
1 1 2
Input
4
Output
2
2 1 1 2
题意:所有的价格从2~n+1,给这些数字涂色,如果一个数a是另一个数b的质因子,则两个数颜色不能相同,问最少的涂色方案
质数涂1,其他涂2就行,因为合数都能被某个素数整除,水题
 
技术分享
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 using namespace std;
 5 
 6 int n;
 7 int a[100005];
 8 int isPrime(int x)
 9 {
10     for(int i=2;i*i<=x;i++)
11         if(x%i==0)return 0;
12     return 1;
13 }
14 int main()
15 {
16     while(~scanf("%d",&n))
17     {
18         memset(a,0,sizeof(a));
19         int ans=1;
20         for(int i=1;i<=n;i++)
21         {
22             if(isPrime(i+1))a[i]=1;
23             else a[i]=2,ans=2;
24         }
25         printf("%d\n",ans);
26         for(int i=1;i<n;i++)
27             printf("%d ",a[i]);
28         printf("%d\n",a[n]);
29     }
30     return 0;
31 }
View Code

 

C. Molly‘s Chemicals
Examples
Input
4 2
2 2 2 2
Output
8
Input
4 -3
3 -6 -3 12
Output
3
题意:
 
D. The Door Problem
Examples
Input
3 3
1 0 1
2 1 3
2 1 2
2 2 3
Output
NO
Input
3 3
1 0 1
3 1 2 3
1 2
2 1 3
Output
YES
Input
3 3
1 0 1
3 1 2 3
2 1 2
1 3
Output
NO
题意:
 
E. The Holmes Children
Examples
Input
7 1
Output
6
Input
10 2
Output
4
题意:
 
F. Sherlock‘s bet to Moriarty
Examples
Input
4 1
1 3
Output
1 2
Input
6 3
1 3
1 4
1 5
Output
2 1 2 3
题意:
 
G. Sherlock and the Encrypted Data
Examples
Input
1
1014 1014
Output
1
Input
2
1 1e
1 f
Output
1
0
Input
2
1 abc
d0e fe23
Output
412
28464
题意:
 
 

 
 
 
 

Codeforces 400 Div.1+Div.2