/images/avatar.png

^_^

Codeforces Round #643 (Div. 2) A~D

A. Sequence with Digits

题意

看题目

题解

模拟,minDigit(x) 等于0 时打断

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0;
ll t;
ll a,k;
ll maxD(ll n)
{
 ll res=n%10;
 while(n)
 {
  res=max(res,n%10);
  n/=10;
 }
 return res;
}
ll minD(ll n)
{
 ll res=n%10;
 while(n)
 {
  res=min(res,n%10);
  n/=10;
 }
 return res;
}
ll cal(ll n)
{
 return n+maxD(n)*minD(n);
}
int main(){
	cin>>t;
	while(t--){
		cin>>a>>k;
		for(ll i=1;i<k;i++)
		{
			//cout<<a<<" "<<i<<" "<<maxD(a)<<" "<<minD(a)<<" "<<endl;
			a=cal(a);
			if(minD(a)==0) break;
		}
		cout<<a<<endl;
	}
	return 0;
}

B. Young Explorers

题意

有一个数组,将它们划分成n组(不用每一个数字都被划分),保证每一组的每个数字都<=这组数字的个数,求最多划分成几组

Codeforces Round #641 (Div. 2) A~D

A. Orac and Factors

题意

对于一个数,每一次操作加上他的最小因子(除1外)

问k次操作后,这个数是多少

题解

奇数找最小因子加一下就变成偶数,偶数最小因子是2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<bits/stdc++.h>
using namespace std;
int n,k,t;
int ans;
int f(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			return i;
		}
	}
	return x;
}
int main(){
	cin>>t;
	while(t--){
		cin>>n>>k;
		if(n&1){
			n+=f(n);
			ans = n+(k-1)*2;
		}
		else{
			ans = n+k*2;	
		}
		cout<<ans<<endl;
	}
	return 0;
}

B. Orac and Models

题意

给一数组,从中选几个数出来,满足严格递增,且对任意相邻下标a,b满足a|b,输出最长子序列的个数

abc167

这个比赛尽犯些sb错🙃,先是把 j 写成 i ,然后把2E5写成1E5

A - Registration

题意

判断字符串T是不是S后加一个字符

题解

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	if(s2.substr(0,s2.length()-1)==s1) puts("Yes");
	else puts("No");
	return 0;
}

不知道strstr为啥就不行

git

git安装

用户名和邮箱

初始化或切换用户名和邮箱

git config --global user.name "XXX"

git config --global user.email "XXX"

查看当前用户名和邮箱

git config --global user.name

git config --global user.email

查看用户名和邮箱列表

git config --list

abc166

A - A?C

题意

abc输出arc反之亦然

题解

1
2
3
4
5
6
7
8
9
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	s[1]=s[1]=='B'? 'R': 'B';
	cout<<s<<endl;
	return 0; 
}

B - Trick or Treat

题意

snack_i被snuke_1,snuke_2..拥有

问有多少个snuke没有snack

abc165

A - We Love Golf

题意

询问在A到B之间是否有C的倍数

题解

特判边界是否满足条件,否则判断左右边界除以C的值是否大于等于1

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b/(double)a == b/a) puts("OK");
    else if(c/(double)a == c/a) puts("OK");
    else if(c/a > b/a){
    	puts("OK");
    	
	}
	else puts("NG");
    return 0;
}

B - 1%

题意

初始有100円,每年利息1%,每年结算时将小数部分抛弃,问多久能达到A円

NC17134

Symmetric Matrix

题目描述

Count the number of n x n matrices A satisfying the following condition modulo m.

  • Ai, j ∈ {0, 1, 2} for all 1 ≤ i, j ≤ n.
  • Ai, j = Aj, i for all 1 ≤ i, j ≤ n.
  • Ai, 1 + Ai, 2 + … + Ai, n = 2 for all 1 ≤ i ≤ n.
  • A1, 1 = A2, 2 = … = An, n = 0.

输入描述

The input consists of several test cases and is terminated by end-of-file. Each test case contains two integers n and m.

Codeforces Round #636 (Div. 3) A~E

A. Candies

题意

给一个数n,找一个数x,满足 x+2x+4x+8x+… = n

题解

等比数列求和,变成2^m

然后枚举,看哪个能整除

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include<bits/stdc++.h>
using namespace std;
long long n,t;
int main(){
	cin>>t;
	long long a[32];
	for(long long i=1;i<=30;i++){
		a[i] = (1<<i) - 1;
	}
	while(t--){
		cin>>n;
		for(long long i=2;i<=30;i++){
			if((double)n/a[i] == n/a[i]){
				cout<<n/a[i]<<endl;
				break;
			}
		}
	}
	
	return 0;
}

B. Balanced Array

题意

给一数n,问是否可以构造一个数列

abc163

A - Circle Pond

题意

求圆周长

题解

ac代码

1
print(int(input())*2*3.14159265)

B - Homework

题意

给定假期的时间和每一项作业完成的时间,求这个假期能玩几天

题解

ac代码

1
2
3
4
5
6
7
n,m = map(int , input().split())
a = list(map(int , input().split()))
s = sum(a)
if n>=s:
    print(n-s)
else:
    print(-1)

C - management

题意

告诉每个员工的老板,询问每个老板有多少个员工