/images/avatar.png

^_^

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

题意

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

hduoj1796

How many integers can you find

Problem Description

Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For example, N=12, and M-integer set is {2,3}, so there is another set {2,3,4,6,8,9,10}, all the integers of the set can be divided exactly by 2 or 3. As a result, you just output the number 7.

牛客练习赛61(部分)

A . 打怪

题解

模拟

ac代码

 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
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("in.txt","r",stdin);
	int t,a,b,c,d;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>d;
		if(b>=c || d<=0) cout<<-1<<endl;
		else{
			int num=0;
			int cx=c;
			bool me=true;
			while(a>0){
				if(me){
					cx-=b; me^=1;
				}
				else{
					a-=d;me^=1;
				}
				if(cx<=0) {
					cx=c;num++;me=true;
				}
			}
			if(num>10000) cout<<-1<<endl;else cout<<num<<endl;
		}
	}
	return 0;
}

B . 吃水果

题解

贪心

NC13611

题目描述

shy有一颗树,树有n个结点。有k种不同颜色的染料给树染色。一个染色方案是合法的,当且仅当对于所有相同颜色的点对(x,y),x到y的路径上的所有点的颜色都要与x和y相同。请统计方案数。

abc161

A - ABC Swap

题意

给三个数a,b,c,交换ab的值,交换ac的值,输出

题解

模拟

ac代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}

B - Popular Vote

题意

有n件商品,每种商品有一价格,给一数m